Installing emacs on openSUSE (and WSL2)
The Setup
Updating my personal laptop to Linux Mint 20.3 Una broke my installation (darn it). And because I have little patience with this kind of things, I decided to give a try to openSUSE Tumbleweed, as I wanted to have a rolling distribution (the other option would have been to go back to Manjaro).
openSUSE by default installs Gnome on Wayland as the default desktop. Which is something I realized when I did my normal process of downloading the current version of emacs source code to configure and compile. It complained that there was no X11 available.
Furthermore, I could try it (again) on WSL2 too. With the advent of Windows 11 Microsoft added WSLg, the graphical support for WSL2. Which, interestingly, is a Wayland compositor (they use Weston, the reference compositor).
A Helpful Person
Sometimes you need some help to get you started. As always, Bozhidar Batsov has us covered, with a post (well, more than one) about Using Emacs on Windows 11 with WSL2.
Awesome, except the instructions are for Ubuntu, and I am on openSUSE. So time to enumerate the steps I took to get it working. These steps worked for both pure openSUSE installation and the WLS2 version.
The Initial Steps
First, the assumption this is a clean install of openSUSE Tumbleweed.
The proper support for Wayland is not yet on an official release, so you can get the version that has GTK support with git clone git://git.sv.gnu.org/emacs.git
, as indicated by Bozhidar.
Interestingly, when downloaded like this, the configure
command is not available. To get it sorted first you need to install the library autoconf
with
sudo zypper install autoconf
and then run from inside the emacs directory this command:
./autogen.sh
With the above you will be able to run ./configure
. But you will still be missing a lot of libraries needed to actually complete the configuration and the running of Emacs.
The Additional Libraries
The first command to run is
sudo zypper install -t pattern devel_basis
This is a pattern within zypper, which means that is a collection of packages instead of the single one. This gets you setup some basic tools and libraries for development.
For Wayland we are using the GTK (Gnome Toolkit) to compile emacs, so we need the development libraries for it:
gtk3-devel
Time to check the version of GCC (the GNU C compiler) that will be used to compile emacs. For openSUSE Tumbleweed (the rolling distribution) that is version 12. We use this information to install the right JIT library
sudo zypper install libgccjit0-devel-gcc12
If you are in one of the LEAP versions of openSUSE and you have a different version of GCC installed, just change the number at the end for the right one (so for version 11 of GCC it would be libgccjit0-devel-gcc11
)
We follow with the GNU library for SSL and TLS:
sudo zypper install libgnutls-devel
Next there are a couple of libraries used to improve the handling of XML and JSON
sudo zypper install libxml2-devel
sudo zypper install libjansson-devel
The same for handling of graphics
sudo zypper install giflib-devel
sudo zypper install libtiff-devel
Time to take care of fonts:
sudo zypper install gnome-tweaks
sudo zypper install texinfo
will setup needed fonts for Emacs to run. It maybe possible that the first one is actually not needed on direct Linux installation. But I went too quick doing installations and didn’t properly check. For the WSL2 version is needed (as you could see from Bozhidar’s post)
Finally a library to allow Emacs to use OpenType fonts:
sudo zypper install libotf-devel
Ok, not finally, finally is now if you want to use a font on Emacs that doesn’t come by default on the installation, which on my case is Fira
sudo zypper install fira-code-fonts
On WSL2
The only real difference for WSL2 with a normal Linux installation is that you need to make sure that the neccessary graphic drivers are installed. Thanksfully they provide those links on the Github repo of WSLg
Without them Emacs will not run.
Time to configure
The command that I used for configuring was (within the emacs directory)
./configure --with-native-compilation --with-mailutils --with-pgtk
The last option is the one that uses the GTK setup that allows you to run in Wayland.
Funky issues
One interesting issue that happened on my laptop with a direct installation of openSUSE is that it couldn’t recognise that I had installed libotf
. To fix that I had to run the configure with some environment variables
LIBOTF_CFLAGS='libotf-config --cflags' LIBOTF_LIBS='libotf-config --libs' \
./configure --with-native-compilation --with-mailutils --with-pgtk
Compile time
This one should be easy, after everything has been installed:
make
If you look at Bozhidar’s post you will see that he uses
make -j8
which tells make
to parallelize up to 8 jobs (if possible). That should allow the system to compile much quicker.
Once it is done execute
src/emacs -Q
This will run the just compiled version of emacs. The -Q
flag will tell Emacs to not load any configuration, so it will be a pure vanilla version. If everything is fine, you can give it a try with your normal configuration removing the -Q
option
And once confirmed that it works you can install it on your system using
sudo make install
The End
And there you go, Emacs running on openSUSE (both pure Linux and WSL2) with Wayland support. Happy usage.