Bug ID | 1205109 |
---|---|
Summary | emacs cannot reach XDG_RUNTIME_DIR |
Classification | openSUSE |
Product | openSUSE Distribution |
Version | Leap 15.4 |
Hardware | All |
OS | openSUSE Leap 15.4 |
Status | NEW |
Severity | Normal |
Priority | P5 - None |
Component | Maintenance |
Assignee | maintenance@opensuse.org |
Reporter | zimtsui@gmail.com |
QA Contact | qa-bugs@suse.de |
Found By | --- |
Blocker | --- |
# Description Emacs checks whether environment variable `XDG_RUNTIME_DIR` exists to determine where a certain socket file should be placed. If `XDG_RUNTIME_DIR` doesn't exist, emacs will fallback to some other location. See <https://git.savannah.gnu.org/cgit/emacs.git/tree/lib-src/emacsclient.c?h=emacs-27.2#n1393> `sudo` defaults to unset all environment variables and set some certain ones. So any program run by `sudo` should miss `XDG_RUNTIME_DIR` in its environment. If I run `sudo emacs-nox`, everything goes expectedly. But if I run `sudo emacs`, emacs prompts `Unable to set up transient service directory: XDG_RUNTIME_DIR "/run/user/0" not available: No such file or directory`. # Possible reason The binary `/usr/bin/emacs` is not built from emacs source, but made by the SUSE package maintainer. The binary checks whether it's run in terminal or X to determine whether it should exec `emacs-nox` or `emacs-x11`. The `/usr/bin/emacs` binary defines an environment variable `XDG_RUNTIME_DIR` as `/run/user/<USER_ID>` arbitrarily. But `/run/user/0` doesn't exist because it should be created by `/etc/profile` in a login shell. And `sudo` doesn't spawn a new login shell. # Reproduction 1. Install `emacs` and `emcas-nox` from zypper, and don't install `emacs-x11`. 1. Restart your computer and don't login as root in any tty, but login as a regular user. 1. `sudo emacs` 1. Quit emacs. 1. You will see the prompt. # Versions openSUSE Leap 15.4 Emacs 27.2 Sudo 1.9.9