6

To have the latest emacs, on ubuntu 22.04 I activated the ppa https://launchpad.net/~ubuntu-elisp/+archive/ubuntu/ppa and installed emacs-snapshot from there. When starting it I get the warning:

You are trying to run Emacs configured with the "pure-GTK" interface under the X Window System. That configuration is unsupported and will lead to sporadic crashes during transfer of large selection data. It will also lead to various problems with keyboard input.

This happens when I log in with either xfce or Ubuntu(standard) on the login screen. My screen manager is lightdm, if that has any relevance here.

Obviously I should not be using this version of emacs or start it with some different environment or command line argument. Is there any way to start it correctly? Is there a more suitable ppa to get a rather new version of emacs?

3 Answers 3

2

Another PPA for Emacs is the one from kelleyk. As of this writing, the latest version it has is 28.1, and it's not built with pgtk so Xorg users won't get that warning.

If you're going to try this one, completely uninstall the emacs from the first PPA before installing this one. You may also need to remove the first PPA too, but I'm not sure. Also, if you want native compilation enabled, you have to explicitly install emacs28-nativecomp.

4

This means that it was compiled with pure-GTK (Wayland). You are seeing this warning as you are using X instead. I am not aware of another ppa, but there probably is one.

Just Compile it Yourself

I recommend to just compile it yourself which is actually very easy and quite fast.

  1. Install all dependencies:

    sudo apt update
    sudo apt install -y autoconf automake bsd-mailx build-essential \
    dbus-x11 debhelper dpkg-dev emacs-bin-common emacs-common g++-10 gawk \
    gcc-10 git gvfs ibus-gtk3 language-pack-en-base libacl1-dev libasound2 \
    libasound2-dev libaspell15 libasyncns0 libatk1.0-0 libatk-bridge2.0-0 \
    libatspi2.0-0 libbrotli1 libc6 libc6 libc6-dev libc6-dev libcairo2 \
    libcairo2-dev libcairo-gobject2 libcanberra0 libcanberra-gtk3-0 \
    libcanberra-gtk3-module libdatrie1 libdb5.3 libdbus-1-3 libdbus-1-dev \
    libdrm2 libegl1 libenchant-2-dev libepoxy0 libflac8 libfontconfig1 \
    libfontconfig1-dev libfreetype6 libfreetype6-dev libgbm1 libgccjit0 \
    libgccjit-10-dev libgcc-s1 libgdk-pixbuf2.0-0 libgif7 libgif-dev \
    libgl1 libglib2.0-0 libglvnd0 libglx0 libgmp10 libgnutls28-dev \
    libgnutls30 libgpm2 libgpm2 libgpm-dev libgraphite2-3 \
    libgstreamer1.0-0 libgstreamer-gl1.0-0 libgstreamer-plugins-base1.0-0 \
    libgtk-3-0 libgtk-3-dev libgudev-1.0-0 libharfbuzz0b libharfbuzz0b \
    libharfbuzz-icu0 libhyphen0 libibus-1.0-5 libice6 libicu70 libisl23 \
    libjansson4 libjansson-dev libjbig0 libjpeg8-dev libjpeg-dev \
    libjpeg-turbo8 liblcms2-2 liblcms2-dev liblockfile1 liblockfile-dev \
    libltdl7 libm17n-0 libm17n-dev libmpc3 libmpfr6 libncurses5-dev \
    libnotify4 libnss-mdns libnss-myhostname libnss-sss libnss-systemd \
    libogg0 liborc-0.4-0 liboss4-salsa2 libotf1 libotf-dev libpango-1.0-0 \
    libpangocairo-1.0-0 libpangoft2-1.0-0 libpixman-1-0 libpng16-16 \
    libpng-dev libpulse0 librsvg2-2 librsvg2-dev libsasl2-2 libsecret-1-0 \
    libselinux1-dev libsm6 libsndfile1 libsoup2.4-1 libsqlite3-0 \
    libsqlite3-dev libssl3 libsss-nss-idmap0 libstdc++6 libsystemd-dev \
    libtdb1 libthai0 libtiff5 libtiff-dev libtinfo-dev libtree-sitter0 \
    libtree-sitter-dev libvorbis0a libvorbisenc2 libvorbisfile3 \
    libwayland-client0 libwayland-cursor0 libwayland-egl1 \
    libwayland-server0 libwebkit2gtk-4.0-dev libwebp7 libwebpdemux2 \
    libwebp-dev libwoff1 libx11-6 libx11-xcb1 libxau6 libxcb1 \
    libxcb-render0 libxcb-shm0 libxcomposite1 libxcursor1 libxdamage1 \
    libxdmcp6 libxext6 libxfixes3 libxfixes-dev libxi6 libxi-dev \
    libxinerama1 libxkbcommon0 libxml2 libxml2-dev libxpm4 libxpm-dev \
    libxrandr2 libxrender1 libxrender-dev libxslt1.1 libxt-dev libyajl2 \
    mailutils procps quilt sharutils texinfo zlib1g-dev
    

    There might be a dialog about the mail server configuration, just select no configuration.

  2. Clone the latest Emacs 29 version into ~/emacs. Change the directory if you want to clone it somewhere else.

    cd ~
    git clone --depth 1 --branch emacs-29 git://git.sv.gnu.org emacs.git
    
  3. Configure and install Emacs

    This step will take some time, and you might be prompted to enter your password once.

    Optional features used (feel free to remove any that you don’t need):

    • --with-native-compilation Use native compilation.
    • --with-mailutils Causes Emacs to rely on GNU Mailutils to retrieve email. It is recommended, and is the default if GNU Mailutils is installed.
    • --with-json Compile with native JSON support. I think this is the default, if libjansson is installed, not sure though.
    • --with-tree-sitter Compile with tree-sitter. Is probably also the default, if tree-sitter is installed.
    • --with-xwidgets Enable use of xwidgets in Emacs buffers (requires gtk3 or macOS Cocoa)
    cd ~/emacs
    export CC="gcc-10" CXX="gcc-10"
    ./autogen.sh
    ./configure --with-native-compilation --with-mailutils --with-json --with-tree-sitter --with-xwidgets
    make -j$(nproc)
    sudo make -j$(nproc) install
    

Keep the directory where Emacs was cloned to, to be able to reinstall (if a step fails), to reconfigure or to uninstall it.

Use Snap

Instead of compiling yourself you could use the 'latest/edge' version of the snap:

sudo snap install emacs --edge --classic
7
  • 1
    To speed up compilation, I'd say make -j $(nproc) to take advantage of all the available cores on your system.
    – g-gundam
    Commented Dec 22, 2022 at 8:57
  • 1
    @g-gundam Thanks for the input, edited the code accordingly. And will use this myself next time :-)
    – Hubisan
    Commented Dec 22, 2022 at 9:11
  • 1
    Please don't use/advice Snap/Flatpak versions of Emacs (or any other programming editor or IDE for that matter). Programming editors/IDEs are built upon external tools, such as git, clangd, pylsp, ispell, you name it… Which means that a good user experience requires the editor to have full access to everything in $PATH — which is not about Snap/Flatpak as they are sandboxes. By mentioning Snap you're opening a non-suspecting user to a can of worms of type "but I installed X, how come Emacs doesn't see it??". These packages shouldn't exist in Snap and Flatpak in the first place.
    – Hi-Angel
    Commented Jun 13 at 5:19
  • 1
    @Hi-Angel I agree, compiling yourself is the way to go. The Emacs snap is using confinement: classic and should therefore be able to access system’s resources in much the same way traditional packages do. So it should not have those problems you mention above.
    – Hubisan
    Commented Jun 14 at 8:35
  • Oh, that's interesting. It's just that I found this post because some other user seems unable to access rg app in a similar situation. I'm curious why then. On an unrelated note: running sudo make install is never good as it will result in untracked files all over the system and potential conflicts. It's easy to create a deb package, there's script at the bottom of this post, just replace ninja install with make install, the version and packages names. I'll upvote your post if you do this 😊
    – Hi-Angel
    Commented Jun 14 at 8:58
3

Currently, there are three ppa's:

  • Kevin Kelley: unofficial builds from series 25.x to 28.x. Currently outdated with last published version stalled at 28.1. Although it has been a "default" ppa for Emacs users on Ubuntu during many years, I do no longer recommend it.
  • Panda Jim: unofficial builds of series 29.x. I recommend this ppa for and up-to-date stable release.
  • "Ubuntu Emacs Lisp" team: The Official ;-) Ubuntu Emacs Daily Snapshot PPA. I am currently using this one and, since I am experiencing problems with later snapshots, I have on hold the 2023.11.31 daily snapshot of version 30.5.

From release 22.04 onward, Ubuntu ships with Gnome on Wayland. For compatibility with the "pure-GTK interface", you need to enter a Wayland session. From the default greeter, gdm3, upon selecting the user, click on the option cog to select "Ubuntu on Wayland" or "GNOME Classic on Wayland".

This is similar if you use the LightDM greeter. However, Xfce has not yet been fully ported to Wayland so you must use compatible builds or build it yourself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.