This used to work, but since a recent update, it hasn't. I'm using spacemacs, with this configuration. Links and files don't open as usual. If I open ansi-term, and type xdg-open test.txt, then I see:

xdg-open: line 617: kde-open5: command not found.

Which makes sense, since I use GNOME, and not KDE. In a normal terminal (gnome-terminal), I don't have any $KDE_x variables, but in the emacs terminal, for some reason I have all kinds of variables set, like $KDE_FULL_SESSION=true. I thought this might be an issue with NixOS's packaging of emacs, but looking where the package is defined (I think), I don't see anything out of the ordinary.

Does anyone know what could be causing this, and/or how to fix it?

  • Is kde-open5 in your $PATH? This doesn't really seem like an Emacs question, but maybe I'm missing something.
    – Drew
    Jan 30, 2019 at 16:10
  • I don't have kde-open5 installed, because I don't use KDE. But somehow Emacs thinks I do.
    – Jonathan
    Jan 30, 2019 at 16:11
  • Please add that info to the question itself. Comments can be deleted at any time. You might also want to M-x debug-on-entry for xdg-open, to see what calls that function and why that function tries to invoke command kde-open5.
    – Drew
    Jan 30, 2019 at 17:54
  • @Drew, that information is already in the question itself. The mystery is not why xdg-open invokes kde-open, that's obvious. It apparently thinks I'm running KDE, because those KDE environment variables are set. But I'm not running KDE, and emacs terminals are the only places where those environment variables are set. The issue is that Emacs has somehow convinced itself that I'm running KDE, and thus tries to open commands like that which don't exist.
    – Jonathan
    Jan 30, 2019 at 18:32
  • 2
    Can you check out your ~/.spacemacs.env file? Possibly try to remove it and regenerate it. There's been some changes in how it works recently and maybe your system got caught in the shuffle. There's a SO article here with a very similar issue askubuntu.com/questions/1095068/…
    – shoshin
    Jan 30, 2019 at 21:06

1 Answer 1


Check out your ~/.spacemacs.env file. The newest version of Spacemacs has a function in the .spacemacs initialization file to load environment variables.

(defun dotspacemacs/user-env ()
  "Environment variables setup.
This function defines the environment variables for your Emacs session. By
default it calls `spacemacs/load-spacemacs-env' which loads the environment
variables declared in `~/.spacemacs.env' or `~/.spacemacs.d/.spacemacs.env'.
See the header of this file for more information."

There's been some changes in how it works recently and maybe the environment variables that don't exist on your system got populated by mistake. You can try to removing the ~/.spacemacs.env file and regenerate with

[M-x] spacemacs/force-init-spacemacs-env

There's an askUbuntu question here with a very similar issue that was resolved this way.

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.