Fedora 40 and a natural but less than ideal outcome with 'alternatives'

July 3, 2024

Fedora, like various Linux distributions, has a system of 'alternatives', where several programs from several different packages can provide alternative versions of the same thing, and which one is used is chosen through symbolic links in /etc/alternatives (Fedora's version appears to be this implementation). These alternatives can have priorities and by default the highest priority version of something gets to be that thing; however, if you manually choose another option, that option is supposed to stick. On a Fedora system, you can see the surprisingly large list of things handled this way with 'alternatives --list' and see about a particular thing with 'alternatives --display <thing>'.

As part of its attempt to move to Wayland, Fedora 40 has opted to package two different builds of Emacs, a "pure GTK" build that does not work well on X11 (or on plain terminals), and a "gtk+x11' build that does work well on X11 and on plain terminals. Which of the two versions gets to be 'emacs' is handled through the alternatives system, and the default is the "pure GTK" version (because of Fedora's love of Wayland). I don't use Wayland, so more or less as soon as I upgraded to Fedora 40, I ran 'alternatives --config emacs' and switched my 'emacs' to the gtk+x11 version, which also sets this alternative to be manually configured and thus it's supposed to be left alone.

Fedora 40 shipped with Emacs 29.3. Recently, Emacs 29.4 was released to deal with a security issue, so of course I updated to it when Fedora had an updated package available. To my unhappy surprise, after the update my 'emacs' was suddenly back to being the pure GTK, Wayland only version. Unfortunately, this outcome is actually a natural one given how everything works, because I left out a critical element of how Emacs works with the alternative system in Fedora. You see, when I manually set my alternatives preferences, I did not set it to 'emacs-gtk+11', because there is no such alternative. Instead, I set it to 'emacs-29.3-gtk+x11', and after the upgrade I had to reset it to 'emacs-29.4-gtk+x11', because that's what now existed.

Quite sensibly, if you have an alternative pointed to something that gets removed, Fedora de-selects that alternative rather than leave you with a definitely non-working configuration. So Fedora removed my (manually set) 'emacs-29.3-gtk+x11' alternative, along with what had been the default 'emacs-29.3' option, and after the package update it had 'emacs-29.4-gtk+x11' (at priority 75) and 'emacs-29.4' (at priority 80, and thus the default). With no manual alternative settings left, it picked the default to be 'emacs', and suddenly I was trying to use the non-working pure GTK version.

This is all perfectly natural and straightforward, and in this situation it more or less has to be implemented this way, but it results in a less than ideal outcome. To solve it, I think you'd need an additional level of alternatives indirection, where 'emacs' pointed to an 'emacs-gtk+x11' or 'emacs-pure' alternative, and then each of these pointed to the appropriate version. Then there would be a chance for the alternatives system to not forget your manual setting over a package upgrade.

(There might be a simpler scheme with some more cleverness in the package update actions, but I think it would still need the extra level of indirection through a 'emacs-gtk+x11' symbolic link.)

All things considered I'm not surprised that Fedora either overlooked this or opted not to go through the extra effort. But still, the current situation is yet another little example of "robot logic".


Comments on this page:

By Anonymous at 2024-07-04 08:44:45:

Fedora's version appears to be this implementation

The link you posted (https://github.com/fedora-sysv/chkconfig) points to 'chkconfig', which to my knowledge is definitely not Fedora's implementation of 'alternatives'. Instead, 'chkconfig' is what used to be used (by various distributions) in the pre-systemd era of SYSV init and the /etc/rc.d directory, that lets you configure what services should be started (if at all) and at what 'runlevel' they should start/stop.

By Anonymous at 2024-07-04 08:47:45:

Wait, I take that back. The same repository does indeed also seem to contain 'alternatives.c', but Lord knows why.

By Doug at 2024-07-04 11:18:13:

Debian solves this issue with the second level of indirection, as you mention. So /usr/bin/emacs is a symlink to /etc/alternatives/emacs, and the latter is itself a symlink to the actual emacs binary you've selected. Apt will manage the re-pointing of the alternative symlink on upgrades.

By Ian Z aka nobrowser at 2024-07-04 11:29:19:

Emacs is one of the things that I now consider "too important to be left to the distribution", and I compile it from upstream source. That means it's not there for me on systems too tiny to run a toolchain, like RaspberryPis, but on those I tend to edit remotely via Tramp anyway.

-- Ian

By cks at 2024-07-04 11:59:56:

Doug, the actual implementation of alternatives in both Fedora and Debian involves '/usr/bin/emacs' being a symbolic link in to /etc/alternatives. The difference is what that alternatives link points to, where Debian appears to point it to a generic name that might not go away on package updates and Fedora points it to a versioned name that is definitely going away on significant enough package updates.

(Whether Debian removes the alternative on upgrades and recreates it depends partly on what the package scripts do. What you want to happen is to remove the alternative only if the package is being removed, not if it's being upgraded.)

By Doug at 2024-07-04 12:25:58:

Yup, you are correct, on my Debain desktop the alternative points to /usr/bin/emacs-gtk, so no mention of a version. I have seen multi-version installs before, in that case the link would be something like emacs28-gtk, with no minor version noted. So that also prevents your issue for minor version upgrades.

Written on 03 July 2024.
« Unix's fsync(), write ahead logs, and durability versus integrity
Structured log formats are not really "plaintext" logs »

Page tools: View Source, View Normal.
Search:
Login: Password:

Last modified: Wed Jul 3 21:03:43 2024
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.