User run-time dir stopped being created at boot
I'm not sure what changed exactly, but I found today that systemd was reporting being in a degrade state, and when I investigated further I was finding that the [email protected] was failing to start.
Sep 14 08:36:26 atlas (systemd)[782]: pam_systemd(systemd-user:session): Failed to stat() runtime directory '/run/user/1000': No such file or directory
Sep 14 08:36:26 atlas (systemd)[782]: pam_systemd(systemd-user:session): Not setting $XDG_RUNTIME_DIR, as the directory is not in order.
Sep 14 08:36:26 atlas systemd[782]: Trying to run as user instance, but $XDG_RUNTIME_DIR is not set.
Sep 14 08:36:26 atlas systemd[1]: [email protected]: Main process exited, code=exited, status=1/FAILURE
Digging into it futher, it appeared that the shell script called by the [email protected] (/usr/lib/bottle-imp/imp-user-runtime-dir.sh) wasn't creating the directory any more.
I've monkey patched the shell script to the below to make it work again (new line is after the # We are the WSLg user, so leave the status quo)
#!/bin/sh
if [ ! -d /mnt/wslg/runtime-dir ]
then
# WSLg is not present, so default to doing the standard thing.
/lib/systemd/systemd-user-runtime-dir $1 $2
exit
fi
# Get the UID of the WSLg runtime directory.
WSLGUID=$(stat -c "%u" /mnt/wslg/runtime-dir)
if [ "$1" = "start" ]
then
# Setting up runtime dir.
# At this point, the WSLg runtime dir will be mounted at this point anyway;
# regardless of UID.
if [ $2 -eq $WSLGUID ]
then
# We are the WSLg user, so leave the status quo.
/lib/systemd/systemd-user-runtime-dir $1 $2
exit
fi
# Otherwise, unmount the runtime dir, and then default to the standard.
/bin/umount /run/user/$2
/lib/systemd/systemd-user-runtime-dir $1 $2
exit
fi
if [ $1 = "stop" ]
then
# Unsetting up runtime dir.
if [ $2 -eq $WSLGUID ]
then
# We are the WSLg user, so leave the status quo.
exit
fi
# Otherwise, default to the standard.
/lib/systemd/systemd-user-runtime-dir $1 $2
fi
Interesting. I haven't experienced this particular issue, but I'll look into it and see if I can replicate it.
Can you let me know your WSL version and Linux distro and version information? Thanks.
Windows 11 24H2 (26100.6584)
WSL:
wsl --version
WSL version: 2.6.1.0
Kernel version: 6.6.87.2-1
WSLg version: 1.0.66
MSRDC version: 1.2.6353
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26100.1-240331-1435.ge-release
Windows version: 10.0.26100.6584
Distro : Arch (because of course it is 😁)
imp --version
imp 1.00
uname -a
Linux atlas 6.6.36.6-microsoft-standard-WSL2+ #4 SMP PREEMPT_DYNAMIC Mon Sep 30 13:04:38 AEST 2024 x86_64 GNU/Linux
systemctl --version
systemd 257 (257.9-1-arch)
+PAM +AUDIT -SELINUX -APPARMOR -IMA +IPE +SMACK +SECCOMP +GCRYPT +GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBCRYPTSETUP_PLUGINS +LIBFDISK +PCRE2 +PWQUALITY +P11KIT +QRENCODE +TPM2 +BZIP2 +LZ4 +XZ +ZLIB +ZSTD +BPF_FRAMEWORK +BTF +XKBCOMMON +UTMP -SYSVINIT +LIBARCHIVE
Let me know if there's anything else you need?