Emacs problems

, ,

On the 3rd of May I updated from Fedora 39 to 40 using dnf system-upgrade.
I am used to having the computer on runlevel 3, so I log in through a virtual console and start X11 with kde using startx.
After the upgrade had finished and I had f40 running, I noticed that startx didn’t work, just produced an error message.
Using another computer I noticed at What's New in Fedora KDE 40? - Fedora Magazine that I had to install kwin-x11 and plasma-workspace-x11 manually and after that I got startx working.

However, then I noticed that emacs doesn’t work on a text-mode virtual console at all, it just says
“(emacs:7934): Gtk-WARNING **: 00:05:36.972: cannot open display:”.
Gtk? On a text-mode virtual console?

When I start it from an X11 session Konsole window, it opens a wide warning dialog window with text:
“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.
Install emacs-gtk+x11 or emacs-lucid package.”
And I couldn’t even copy/paste from that window, had to type the warning!

But I already HAD emacs-gtk+x11-1:29.3-6.fc40.x86_64 installed, and after installing emacs-lucid the same warning showed again the next time I started emacs!

Is there an actual working solution for these things? I need emacs, vi is too horrible to use for actual editing and it doesn’t have gnus.

1 Like

If you run emacs -nw instead of just emacs, does that work? If not, try installing the emacs-nw package and running emacs-nw.

2 Likes

Yes, emacs -nw works in text mode console, so it’s a valid workaround.
But when I run emacs in X11, I’d still like to have it open its own window. Is there a cure for the “pure-GTK” warning? So far I haven’t encountered the problems it warns about, but who knows when I will…

Sorry, I don’t know about that one. Does running emacs-lucid avoid the pure-GTK warning?

1 Like

Yes, emacs-lucid doesn’t show the “pure-GTK” warning. It looks a bit different, but that’s no problem.
Thank you.
I’d still like to be able to use the same simple command for emacs both in virtual console and in X11…

1 Like

Actually emacs-lucid also works in the tty consoles, I just tried, so I guess I’ll use
alias emacs=emacs-lucid
as long as necessary.

1 Like

I had the same issue, just now. What I discovered was that my Fedora 40 installation was running X11, when I had expected it was running Wayland. I logged out, switched to Wayland, and voila, emacs ran as expected.

Additionally, you could consider using alternatives to instead of using the alias solution.

1 Like

If you have the emacs-gtk+x11 package installed, you can also run emacs-gtk+x11 which seems to have the same appearance as plan emacs did in prior versions of Fedora.

As @adpacifico mentions, you can also use alternatives to make emacs-gtk+x11 run by default (without an alias). For example:

$ alternatives --display emacs
emacs - status is auto.
link currently points to /usr/bin/emacs-29.3
/usr/bin/emacs-29.3-gtk+x11 - priority 75
/usr/bin/emacs-29.3 - priority 80
/usr/bin/emacs-29.3-lucid - priority 70
Current `best’ version is /usr/bin/emacs-29.3.

$ sudo alternatives --set emacs /usr/bin/emacs-29.3-gtk+x11

$ alternatives --display emacs
emacs - status is manual.
link currently points to /usr/bin/emacs-29.3-gtk+x11
/usr/bin/emacs-29.3-gtk+x11 - priority 75
/usr/bin/emacs-29.3 - priority 80
/usr/bin/emacs-29.3-lucid - priority 70
Current `best’ version is /usr/bin/emacs-29.3.

Now when I type just emacs, I get the gtk+x11 version running.

2 Likes

Is there a way to set it to emacs-gtk+x11? So it doesn’t break when Emacs is updated?

I’ve tried this but got an error:

$ LC_ALL=C sudo alternatives --set emacs emacs-gtk+x11
emacs-gtk+x11 has not been configured as an alternative for emacs

You need to use the full path to the executable (or whatever is shown by the results of “alternatives --display emacs”. For example:

$ alternatives --display emacs
emacs - status is auto.
 link currently points to /usr/bin/emacs-pgtk
/usr/bin/emacs-gtk+x11 - priority 75
/usr/bin/emacs-lucid - priority 70
/usr/bin/emacs-pgtk - priority 80

$ sudo alternatives --set emacs emacs-gtk+x11
emacs-gtk+x11 has not been configured as an alternative for emacs

$ sudo alternatives --set emacs /usr/bin/emacs-gtk+x11

I think possibly the reason it broke before was that the alternative included the version number (emacs-29.3-gtk+x11) so that when you upgraded emacs, it broke the symlinks used by alternatives. Now, the version isn’t included so the links won’t break (hopefully).

Following up on my previous update, it does look like this was fixed here:
Bug 2277689 - emacs alternatives reset to default (/usr/bin/emacs-29.3) after update

Possibly by this PR:
#42 Reduce use of alternatives

and this release:
emacs-29.4-5.fc40 / FEDORA-2024-cf40c8f40b