Forum › Forums › General › Tips and Tricks › Fix App-select XDG_RUNTIME_DIR Error
- This topic has 7 replies, 4 voices, and was last updated Jun 8-12:28 pm by anticapitalX.
-
AuthorPosts
-
June 8, 2026 at 2:38 am #206183
anticapitalX
Memberif you get bellow error when running app-select :
$ app-select Traceback (most recent call last): File "/usr/local/bin/app-select", line 55, in <module> if os.environ['XDG_RUNTIME_DIR']: ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^ File "<frozen os>", line 717, in __getitem__ KeyError: 'XDG_RUNTIME_DIR'a workaround was to execute this :
export XDG_RUNTIME_DIR = ""
but for dinit I was able to fix it permanently by creating a service :
Add to ~/.bash_profile:export XDG_RUNTIME_DIR=/run/user/$(id -u)Then create the directory:
sudo mkdir -p /run/user/1000 sudo chown demo:demo /run/user/1000 sudo chmod 700 /run/user/1000Also /run/user/1000 won’t survive reboots since /run is tmpfs. Fix that by adding a dinit service. Create /etc/dinit.d/xdg-runtime:
sudo nano /etc/dinit.d/xdg-runtime
Content:type = scripted command = /bin/sh -c "install -d -m700 -o demo -g demo /run/user/1000" depends-on = tmpfsEnable it:
sudo dinitctl enable xdg-runtimeLet's accept antiX as it is
Pure and Elegant by its natureJune 8, 2026 at 6:00 am #206188
sybokMemberIs the error an important indicator that something is wrong with the environment (and it is highly desirable to fix it) or should the Exception-failing condition
if os.environ['XDG_RUNTIME_DIR']
be replaced with e.g. the following one with 2-clauses (Python does lazy evaluation, hence it stops after the first one if False):
if 'XDG_RUNTIME_DIR' in os.environ and os.environ['XDG_RUNTIME_DIR']:
?June 8, 2026 at 6:41 am #206189anticapitalX
MemberThank you @sybok for the great observation.
You are absolutely right on both points.
The error IS an indicator that something is missing from the environment — specifically, when running antiX with dinit and no display manager (like slimski), the XDG_RUNTIME_DIR variable is never set because there is no logind/elogind session manager to create it automatically.
So the fix has two valid layers:
1. The environment fix (what I did):
Create /run/user/1000 on boot via a dinit service, and export XDG_RUNTIME_DIR in ~/.bash_profile. This is the correct approach for a dinit + no-DM setup.2. The code fix you suggested:
Replacing:if os.environ['XDG_RUNTIME_DIR']:with:
if 'XDG_RUNTIME_DIR' in os.environ and os.environ['XDG_RUNTIME_DIR']:…would make app-select more robust and prevent the hard crash for users who don’t have XDG_RUNTIME_DIR set. Instead of an unhandled KeyError, it would simply treat the condition as False and continue gracefully.
moreover the Python fix protects everyone regardless of their init system or session manager , so Perhaps the code fix could be submitted as a patch @Dave?
- This reply was modified 3 months, 2 weeks ago by anticapitalX.
Let's accept antiX as it is
Pure and Elegant by its natureJune 8, 2026 at 8:07 am #206194
sybokMemberOne could also make the following extension:
if 'XDG_RUNTIME_DIR' not in os.environ: # Display a pop-up message Gtk.MessageDialog(..., message_type=Gtk.MessageType.INFO, ...)? print('\nBang the drum loudly - something is wrong, "XDG_RUNTIME_DIR" not in "os.environ"!\n') elif os.environ['XDG_RUNTIME_DIR']: # Proceed as before else: # Proceed as beforeThis would allow not passing the situation (and possible issue) silently.
June 8, 2026 at 8:46 am #206198anti-apXos
Memberspecifically, when running antiX with dinit and no display manager (like slimski), the XDG_RUNTIME_DIR variable is never set because there is no logind/elogind session manager to create it automatically.
turnstiled will set XDG_RUNTIME_DIR to /run/user/${UID} even when logging in on a TTY. If turnstiled is disabled, starting a desktop using desktop-session will still set XDG_RUNTIME_DIR to /tmp/${UID}/.run aas a fallback like previous versions of antix. I guess you must be using neither?
It does seem like app-select should be able to continue even if XDG_RUNTIME_DIR is not set, maybe just using /tmp like some other applications do, however it’s not uncommon for apps to fail when XDG_RUNTIME_DIR is not set (pipewire does, for example). I guess using /tmp could be considered a security issue since anyone has access to it.
"--"
June 8, 2026 at 9:21 am #206200anticapitalX
Memberhttps://www.antixforum.com/forums/topic/what-are-you-here-with-today/page/401/#post-206187
i posted my setup in “what are you here with today” topic , and yes , I don’t have turnstiled .
i have purged slimski , and I was also able to disable seatd , but i cannot purge it , because it removes xorg-server .
anyway i was able to startx from tty1 , then i added a script to /etc/dinit.d/boot.d/tty1 to automatically start the graphical environment.
at the moment I’m not sure the command is startx , or icewm-session .
does it make any difference?
by the way i had to edit and create many files including.Xresources and .xinitrc , in order my setup to workLet's accept antiX as it is
Pure and Elegant by its natureJune 8, 2026 at 11:35 am #206212
DaveForum AdminHere is the script that desktop-session uses to set the xdg variables. It may be beneficial to you to download and add to the standard startx routine.
https://gitlab.com/antiX-Linux/desktop-session-antix/-/blob/master/desktop-session-lib/desktop-session-xdg-dirs.sh?ref_type=headsComputers are like air conditioners. They work fine until you start opening Windows. ~Author Unknown
June 8, 2026 at 12:28 pm #206217anticapitalX
Member@Dave — since I don’t have desktop-session installed, would it be correct to:
-Save the script locally, for example to /usr/local/lib/desktop-session-xdg-dirs.sh
-Source it from ~/.xinitrc before launching icewm-session, like this:/usr/local/lib/desktop-session-xdg-dirs.sh exec icewm-sessionOne thing I notice in the script is that it calls echo_variable, say, and warn functions which appear to be defined elsewhere in desktop-session. Without the full desktop-session environment, those calls would fail. Should I strip those helper function calls out and use plain export statements instead, or is there a cleaner way to use just this script standalone?
——
Edit :
Alright here is the cleaned-up version of the script with all the echo_variable, say, and warn calls stripped out, ready to use without desktop-session.I need to save this to /usr/local/lib/desktop-session-xdg-dirs.sh and update my ~/.xinitrc.
This approach is cleaner than my current dinit service + bash_profile combo because it sets all XDG variables in one place, right before the session starts, which is exactly when they’re needed.
thank you @Dave for sharing the above link .
the first time i tried to run app-select , it gave me this icon related error , then I run lxappearance , selected an icon theme , and applied , and the error is gone.
the secound time it gave me this Xdg-runtime error .
for now I have found my workaround, but If it is possible for you update the app-select code , to by-pass these fatal errors , for some people like me that live in a desktop-sessionLess antiX.
thank youAttachments:
Let's accept antiX as it is
Pure and Elegant by its nature -
AuthorPosts
- You must be logged in to reply to this topic.