On WSL distro with systemd enabled, directory `$XDG_RUNTIME_DIR` is removed minutes after start and breaks apps
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 33.7k
- Forks
- 1.8k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 116
Description
### Windows Version
Microsoft Windows [Version 10.0.26100.6725]
### WSL Version
2.6.1.0
### Are you using WSL 1 or WSL 2?
- [x] WSL 2
- [ ] WSL 1
### Kernel Version
6.6.87.2-microsoft-standard-WSL2
### Distro Version
Ubuntu 25.04
### Other Software
Podman desktop on Windows natively and podman installed on WSL distro
### Repro Steps
This is a followup to #10498 which still presents the same problems.
In a WSL distro like Ubuntu with Systemd enabled, the `$XDG_RUNTIME_DIR` directory gets deleted exactly 3 minutes after boot.
This presents a problem to applications which uses $XDG_RUNTIME_DIR like Podman:
```sh
❯ podman ps
Failed to obtain podman configuration: lstat /run/user/1000: no such file or directory
```
If no systemd is used, $XDG_RUNTIME_DIR is mounted to a directory in user's home and the problem with apps like Podman doesn't happen.
It works fine in these 3 minutes after startup where the `/run/user/1000` directory exists (my user id is 1000).
Below is a capture that monitored the directory:
```sh
❯ echo $XDG_RUNTIME_DIR
/run/user/1000/
❯ ll $XDG_RUNTIME_DIR
Permissions Size User Date Modified Name
drwx------ - carlosedp 3 Oct 18:21 containers/
drwx-----T - carlosedp 3 Oct 18:21 libpod/
❯ sudo inotifywait -m /run/user/1000
Setting up watches.
Watches established.
/run/user/1000/ ATTRIB,ISDIR libpod
/run/user/1000/ ATTRIB,ISDIR libpod
/run/user/1000/ CREATE,ISDIR systemd
/run/user/1000/ CREATE bus
/run/user/1000/ ATTRIB bus
/run/user/1000/ CREATE,ISDIR gnupg
/run/user/1000/ CREATE pk-debconf-socket
/run/user/1000/ ATTRIB pk-debconf-socket
/run/user/1000/ CREATE,ISDIR podman
/run/user/1000/ CREATE,ISDIR pulse
/run/user/1000/ OPEN,ISDIR pulse
/run/user/1000/ CLOSE_NOWRITE,CLOSE,ISDIR pulse
/run/user/1000/ CREATE wayland-0
/run/user/1000/ CREATE wayland-0.lock
/run/user/1000/ OPEN,ISDIR
/run/user/1000/ ACCESS,ISDIR
/run/user/1000/ DELETE wayland-0.lock
/run/user/1000/ DELETE wayland-0
/run/user/1000/ OPEN,ISDIR pulse
/run/user/1000/ ACCESS,ISDIR pulse
/run/user/1000/ CLOSE_NOWRITE,CLOSE,ISDIR pulse
/run/user/1000/ DELETE,ISDIR pulse
/run/user/1000/ OPEN,ISDIR podman
/run/user/1000/ ACCESS,ISDIR podman
/run/user/1000/ CLOSE_NOWRITE,CLOSE,ISDIR podman
/run/user/1000/ DELETE,ISDIR podman
/run/user/1000/ DELETE pk-debconf-socket
/run/user/1000/ OPEN,ISDIR gnupg
/run/user/1000/ ACCESS,ISDIR gnupg
/run/user/1000/ ACCESS,ISDIR gnupg
/run/user/1000/ CLOSE_NOWRITE,CLOSE,ISDIR gnupg
/run/user/1000/ DELETE,ISDIR gnupg
/run/user/1000/ DELETE bus
/run/user/1000/ OPEN,ISDIR systemd
/run/user/1000/ ACCESS,ISDIR systemd
/run/user/1000/ ACCESS,ISDIR systemd
/run/user/1000/ CLOSE_NOWRITE,CLOSE,ISDIR systemd
/run/user/1000/ DELETE,ISDIR systemd
/run/user/1000/ OPEN,ISDIR containers
/run/user/1000/ ACCESS,ISDIR containers
/run/user/1000/ CLOSE_NOWRITE,CLOSE,ISDIR containers
/run/user/1000/ DELETE,ISDIR containers
/run/user/1000/ OPEN,ISDIR libpod
/run/user/1000/ ACCESS,ISDIR libpod
/run/user/1000/ ACCESS,ISDIR libpod
/run/user/1000/ CLOSE_NOWRITE,CLOSE,ISDIR libpod
/run/user/1000/ DELETE,ISDIR libpod
/run/user/1000/ ACCESS,ISDIR
/run/user/1000/ CLOSE_NOWRITE,CLOSE,ISDIR
^C
❯ ll $XDG_RUNTIME_DIR
"/run/user/1000/": No such file or directory (os error 2)
```
Here's what I found on journal:
```
❯ journalctl -xe|grep "/run/user/1000"
Oct 03 18:21:48 CarlosEDP-Win systemd[1]: Starting user-runtime-dir@1000.service - User Runtime Directory /run/user/1000...
Oct 03 18:21:48 CarlosEDP-Win systemd[1]: Finished user-runtime-dir@1000.service - User Runtime Directory /run/user/1000.
Oct 03 18:22:17 CarlosEDP-Win sudo[1069]: carlosedp : TTY=pts/0 ; PWD=/home/carlosedp ; USER=root ; COMMAND=/usr/bin/inotifywait -m /run/user/1000
Oct 03 18:23:38 CarlosEDP-Win systemd[1]: Stopping user-runtime-dir@1000.service - User Runtime Directory /run/user/1000...
Oct 03 18:23:38 CarlosEDP-Win systemd[1]: Stopped user-runtime-dir@1000.service - User Runtime Directory /run/user/1000.
❯ systemctl status user-runtime-dir@1000
Found existing alias for "systemctl status". You should use: "sc-status"
○ user-runtime-dir@1000.service - User Runtime Directory /run/user/1000
Loaded: loaded (/usr/lib/systemd/system/user-runtime-dir@.service; static)
Active: inactive (dead) since Fri 2025-10-03 18:23:38 -03; 7min ago
Duration: 1min 49.197s
Invocation: 72fcd8bd188e43dd983daa39d1a57b74
Docs: man:user@.service(5)
Process: 740 ExecStart=/usr/lib/systemd/systemd-user-runtime-dir start 1000 (code=exited, status=0/SUCCESS)
Process: 1394 ExecStop=/usr/lib/systemd/systemd-user-runtime-dir stop 1000 (code=exited, status=0/SUCCESS)
Main PID: 740 (code=exited, status=0/SUCCESS)
Mem peak: 1.5M
CPU: 9ms
Oct 03 18:21:48 CarlosEDP-Win systemd[1]: Starting user-runtime-dir@1000.service - User Runtime Directory /run/user/1000...
Oct 03 18:21:48 CarlosEDP-Win systemd[1]: Finished user-runtime-dir@1000.service - User Runtime Directory /run/user/1000.
Oct 03 18:23:38 CarlosEDP-Win systemd[1]: Stopping user-runtime-dir@1000.service - User Runtime Directory /run/user/1000...
Oct 03 18:23:38 CarlosEDP-Win systemd[1]: user-runtime-dir@1000.service: Deactivated successfully.
Oct 03 18:23:38 CarlosEDP-Win systemd[1]: Stopped user-runtime-dir@1000.service - User Runtime Directory /run/user/1000.
```
### Expected Behavior
To have the $XDG_RUNTIME_DIR persist
### Actual Behavior
Directory disappears and break apps.
### Diagnostic Logs
[WslLogs-2025-10-03_18-20-55.zip](https://github.com/user-attachments/files/22688373/WslLogs-2025-10-03_18-20-55.zip)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure on WSL 2 with systemd enabled and inspect the systemd journal for user-runtime-dir@1000.service, especially its start and stop events. Compare the runtime-directory lifecycle with the no-systemd case and verify that /run/user/1000 remains available after startup and that Podman continues to run.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100