WSL: `mkdir /run/user/1000/: permission denied` after WSL 2.0.0
Windows Version
Microsoft Windows [Version 10.0.22631.2338]
WSL Version
2.0.0.0
Are you using WSL 1 or WSL 2?
- WSL 2
- WSL 1
Kernel Version
5.15.123.1-1
Distro Version
Ubuntu 22.04
Other Software
No response
Repro Steps
I’m sorry but I’m not sure if this issue happened after upgrading to 2.0.0 or after running wsl --manage Ubuntu --set-sparse true, since I did both at once.
Some programs I have, like chezmoi, is now failing:
$ chezmoi update
chezmoi: mkdir /run/user/1000/: permission denied
Expected Behavior
To work as it did before.
Actual Behavior
$ chezmoi update
chezmoi: mkdir /run/user/1000/: permission denied
Diagnostic Logs
No logs.
- This is apparently related to https://github.com/microsoft/WSL/issues/10473, but since my problem happened after upgrading to 2.0.0 I’m reporting it separately.
The workaround is to:
sudo mkdir /run/user/1000 && sudo chmod 700 /run/user/1000 && sudo chown $(whoami): /run/user/1000
Which I saw somewhere but I don’t remember where.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 23
- Comments: 27 (2 by maintainers)
FYI: realized only now that this is a duplicate of https://github.com/microsoft/WSL/issues/10496 and https://github.com/microsoft/WSL/issues/10552. Disabling
systemd-networkd.disableas mentioned there solves the issue. Additionally, as discussed there (and in related issue https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/2036358), this is more a ubuntu/systemd issue than a WSL2 issue, so probably this issue could be closed?Ok, issue happened again while WSL was even running. A restart isn’t required to trigger the issue apparently.
WslLogs-2023-09-25_20-35-57.zip
I found it may be a bug with systemd and could be fixed by this comment:
https://github.com/microsoft/WSL/issues/10496#issuecomment-2094910556
Face the same issue, and I realize
/run/user/1000/is created successful at wsl starts, but is deleted by some process after about 2min.@appselskapet See here.
FYI: i see also a similar issue: since quite a while, after starting wsl i initially get the “normal” /usr/user/1000 for default user but then fairly quickly something removes the whole directory with all files. A ‘ssh localhost’ does recreate them and from then on all the files stay as expected (to the extent i have to stay logged in via ssh, as soon as i log out the files get quickly removed). And yes, i also have systemd enabled (and currently run it with wsl 2.0.4.0 …)
add this start up script to your .profile start_script.txt sudo -i chown 1000:1000 /run/user/1000 logout env | grep DBUS should show DBUS_STARTER_ADDRESS=unix:path=/run/user/1000/bus hope this helps
Will do, as soon as I can reproduce the issue again. As mentioned, it seems to happen randomly after fixing the permissions manually. Rebooting WSL or Windows does not immediately trigger the issue, apparently.
Yes, I forgot to mention that.