![](https://seccdn.libravatar.org/avatar/a895f78a81a109471893519443e4d933.jpg?s=120&d=mm&r=g)
http://bugzilla.opensuse.org/show_bug.cgi?id=1205109
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=ema...
`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/