WSL icon indicating copy to clipboard operation
WSL copied to clipboard

systemd user instance does not work in 2.5.x

Open gasuketsu opened this issue 6 months ago • 11 comments

Windows Version

Microsoft Windows [Version 10.0.26100.4202]

WSL Version

2.5.7.0

Are you using WSL 1 or WSL 2?

  • [x] WSL 2
  • [ ] WSL 1

Kernel Version

6.6.87.1-1

Distro Version

archilinux

Other Software

No response

Repro Steps

perform systemctl --user status as non-root user

Expected Behavior

systemd user instance is available and systemctl --user status shows status of current user's instance as below. (This worked as expected in WSL 2.4.13)

❯ systemctl --user status
● qube
    State: running
    Units: 136 loaded (incl. loaded aliases)
     Jobs: 0 queued
   Failed: 0 units
    Since: Tue 2025-06-03 23:36:14 JST; 14s ago
  systemd: 257.6-1-arch
   CGroup: /user.slice/user-1000.slice/[email protected]
           └─init.scope
             ├─194 /usr/lib/systemd/systemd --user
             └─196 "(sd-pam)"

Actual Behavior

❯ systemctl --user status
Failed to connect to user scope bus via local transport: No such file or directory

~
❯

Diagnostic Logs

WslLogs-2025-06-03_23-28-41.zip

gasuketsu avatar Jun 03 '25 14:06 gasuketsu

Diagnostic information
.wslconfig found
Detected appx version: 2.5.7.0

github-actions[bot] avatar Jun 03 '25 14:06 github-actions[bot]

Thank you for reporting this @gasuketsu. Unfortunately I can't reproduce this from a fresh archlinux install. Could you share the output of journalctl when this reproduces ?

OneBlue avatar Jun 03 '25 19:06 OneBlue

Thank you for your response @OneBlue. Attached file contains output of journalctl from boot.

journalctl.log

gasuketsu avatar Jun 04 '25 12:06 gasuketsu

Interesting, I don't see anything wrong in there. What's the output of journalctl [email protected] ? Assuming that 1000 is your user's UID.

OneBlue avatar Jun 04 '25 19:06 OneBlue

@OneBlue Yes, 1000 is my UID and following is snippet of journalctl -u [email protected].

-- Boot f4596cc3c174424692995312d87ae63e --
Jun 05 09:22:21 qube systemd[1]: Starting User Manager for UID 1000...
Jun 05 09:22:21 qube (systemd)[218]: pam_warn(systemd-user:setcred): function=[pam_sm_setcred] flags=0x8002 service=[sy>
Jun 05 09:22:21 qube (systemd)[218]: pam_unix(systemd-user:session): session opened for user tharada(uid=1000) by thara>
Jun 05 09:22:21 qube systemd[218]: Queued start job for default target Main User Target.
Jun 05 09:22:21 qube systemd[218]: Created slice User Application Slice.
Jun 05 09:22:21 qube systemd[218]: Reached target Paths.
Jun 05 09:22:21 qube systemd[218]: Reached target Timers.
Jun 05 09:22:21 qube systemd[218]: Starting D-Bus User Message Bus Socket...
Jun 05 09:22:21 qube systemd[218]: Listening on GnuPG network certificate management daemon.
Jun 05 09:22:21 qube systemd[218]: Listening on GnuPG cryptographic agent and passphrase cache (access for web browsers>
Jun 05 09:22:21 qube systemd[218]: Listening on GnuPG cryptographic agent and passphrase cache (restricted).
Jun 05 09:22:21 qube systemd[218]: Listening on GnuPG cryptographic agent (ssh-agent emulation).
Jun 05 09:22:21 qube systemd[218]: Listening on GnuPG cryptographic agent and passphrase cache.
Jun 05 09:22:21 qube systemd[218]: Listening on GnuPG public key management service.
Jun 05 09:22:21 qube systemd[218]: Listening on D-Bus User Message Bus Socket.
Jun 05 09:22:21 qube systemd[218]: Reached target Sockets.
Jun 05 09:22:21 qube systemd[218]: Reached target Basic System.
Jun 05 09:22:21 qube systemd[218]: Reached target Main User Target.
Jun 05 09:22:21 qube systemd[218]: Startup finished in 113ms.
Jun 05 09:22:21 qube systemd[1]: Started User Manager for UID 1000.
[tharada@qube ~]$ systemctl --user status
Failed to connect to user scope bus via local transport: No such file or directory
[tharada@qube ~]$ 

gasuketsu avatar Jun 05 '25 00:06 gasuketsu

Interesting, looks like the session got created, but you somehow can't access it. Can you share the output of findmnt after you get this error ?

OneBlue avatar Jun 05 '25 01:06 OneBlue

@OneBlue Here you go.

❯ systemctl --user status
Failed to connect to user scope bus via local transport: No such file or directory

~
❯ findmnt
TARGET                       SOURCE FSTYPE      OPTIONS
/                            /dev/sdc
│                                   ext4        rw,relatime,discard,errors=remount-ro,data=ordered
├─/usr/lib/modules/6.6.87.1-microsoft-standard-WSL2
│                            none   overlay     rw,nosuid,nodev,noatime,lowerdir=/modules,upperdir=/lib/modules/6.6.87.1
├─/mnt/wsl                   none   tmpfs       rw,relatime
├─/usr/lib/wsl/drivers       drivers
│                                   9p          ro,nosuid,nodev,noatime,aname=drivers;fmask=222;dmask=222,cache=5,access
├─/mnt/wslg                  none   tmpfs       rw,relatime
│ ├─/mnt/wslg/distro         /dev/sdc
│ │                                 ext4        ro,relatime,discard,errors=remount-ro,data=ordered
│ ├─/mnt/wslg/versions.txt   none[/etc/versions.txt]
│ │                                 overlay     rw,relatime,lowerdir=/systemvhd,upperdir=/system/rw/upper,workdir=/syste
│ ├─/mnt/wslg/doc            none[/usr/share/doc]
│ │                                 overlay     rw,relatime,lowerdir=/systemvhd,upperdir=/system/rw/upper,workdir=/syste
│ └─/mnt/wslg/run/user/1000  tmpfs  tmpfs       rw,nosuid,nodev,relatime,size=1224984k,nr_inodes=306246,mode=700,uid=100
│   └─/mnt/wslg/run/user/1000
│                            tmpfs  tmpfs       rw,nosuid,nodev,noexec,relatime,mode=755
├─/usr/lib/wsl/lib           none   overlay     rw,nosuid,nodev,noatime,lowerdir=/gpu_lib_packaged:/gpu_lib_inbox,upperd
├─/init                      rootfs[/init]
│                                   rootfs      ro,size=6119900k,nr_inodes=1529975
├─/dev                       none   devtmpfs    rw,nosuid,relatime,size=6119900k,nr_inodes=1529975,mode=755
│ ├─/dev/pts                 devpts devpts      rw,nosuid,noexec,noatime,gid=5,mode=620,ptmxmode=000
│ ├─/dev/shm                 none   tmpfs       rw,nosuid,nodev,noatime
│ ├─/dev/hugepages           hugetlbfs
│ │                                 hugetlbfs   rw,nosuid,nodev,relatime,pagesize=2M
│ └─/dev/mqueue              mqueue mqueue      rw,nosuid,nodev,noexec,relatime
├─/sys                       sysfs  sysfs       rw,nosuid,nodev,noexec,noatime
│ ├─/sys/fs/cgroup           cgroup2
│ │                                 cgroup2     rw,nosuid,nodev,noexec,relatime,nsdelegate
│ ├─/sys/kernel/debug        debugfs
│ │                                 debugfs     rw,nosuid,nodev,noexec,relatime
│ ├─/sys/kernel/tracing      tracefs
│ │                                 tracefs     rw,nosuid,nodev,noexec,relatime
│ ├─/sys/fs/fuse/connections fusectl
│ │                                 fusectl     rw,nosuid,nodev,noexec,relatime
│ └─/sys/kernel/config       configfs
│                                   configfs    rw,nosuid,nodev,noexec,relatime
├─/proc                      proc   proc        rw,nosuid,nodev,noexec,noatime
│ └─/proc/sys/fs/binfmt_misc binfmt_misc
│                                   binfmt_misc rw,relatime
├─/run                       none   tmpfs       rw,nosuid,nodev,mode=755
│ ├─/run/lock                none   tmpfs       rw,nosuid,nodev,noexec,noatime
│ ├─/run/shm                 none   tmpfs       rw,nosuid,nodev,noatime
│ ├─/run/user                none   tmpfs       rw,nosuid,nodev,noexec,noatime,mode=755
│ │ └─/run/user              none[/run/user]
│ │   │                             tmpfs       rw,relatime
│ │   └─/run/user/1000       tmpfs  tmpfs       rw,nosuid,nodev,relatime,size=1224984k,nr_inodes=306246,mode=700,uid=100
│ │     └─/run/user/1000     tmpfs  tmpfs       rw,nosuid,nodev,noexec,relatime,mode=755
│ ├─/run/credentials/systemd-journald.service
│ │                          tmpfs  tmpfs       ro,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mo
│ ├─/run/credentials/systemd-resolved.service
│ │                          tmpfs  tmpfs       ro,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mo
│ ├─/run/credentials/systemd-networkd.service
│ │                          tmpfs  tmpfs       ro,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mo
│ ├─/run/credentials/[email protected]
│ │                          tmpfs  tmpfs       ro,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mo
│ └─/run/credentials/console-getty.service
│                            tmpfs  tmpfs       ro,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mo
├─/tmp/.X11-unix             none[/.X11-unix]
│                                   tmpfs       ro,relatime
├─/mnt/c                     C:\    9p          rw,noatime,aname=drvfs;path=C:\;uid=1000;gid=1000;symlinkroot=/mnt/,cach
└─/tmp                       tmpfs  tmpfs       rw,nosuid,nodev,nr_inodes=1048576
  └─/tmp/.X11-unix           none[/.X11-unix]
                                    tmpfs       ro,relatime

gasuketsu avatar Jun 05 '25 02:06 gasuketsu

@OneBlue Seems that this issue is similar to #13042.

There is no socket file /run/user/1000/bus when I get error in systemctl --user status. After performing sudo systemctl restart [email protected], socket file /run/user/1000/bus exists and systemctl --user status works as expected as below.

~
❯ systemctl --user status
Failed to connect to user scope bus via local transport: No such file or directory

~
❯ ls -l /run/user/1000/
total 0
drwxr-xr-x 3 tharada tharada 60 Jun  6 23:51 dbus-1/
drwxr-xr-x 2 tharada tharada 80 Jun  6 23:51 pulse/
lrwxrwxrwx 1 root    root    31 Jun  6 23:51 wayland-0 -> /mnt/wslg/runtime-dir/wayland-0=
lrwxrwxrwx 1 root    root    36 Jun  6 23:51 wayland-0.lock -> /mnt/wslg/runtime-dir/wayland-0.lock

~
❯ sudo systemctl restart [email protected]
[sudo] password for tharada:

~ took 2s
❯ ls -l /run/user/1000/
total 0
srw-rw-rw- 1 tharada tharada   0 Jun  6 23:52 bus=
drwxr-xr-x 3 tharada tharada  60 Jun  6 23:51 dbus-1/
drwx------ 2 tharada tharada 160 Jun  6 23:52 gnupg/
drwxr-xr-x 2 tharada tharada  80 Jun  6 23:51 pulse/
drwxr-xr-x 5 tharada tharada 140 Jun  6 23:52 systemd/
lrwxrwxrwx 1 root    root     31 Jun  6 23:51 wayland-0 -> /mnt/wslg/runtime-dir/wayland-0=
lrwxrwxrwx 1 root    root     36 Jun  6 23:51 wayland-0.lock -> /mnt/wslg/runtime-dir/wayland-0.lock

~
❯ systemctl --user status
● qube
    State: running
    Units: 144 loaded (incl. loaded aliases)
     Jobs: 0 queued
   Failed: 0 units
    Since: Fri 2025-06-06 23:51:59 JST; 10s ago
  systemd: 257.6-1-arch
   CGroup: /user.slice/user-1000.slice/[email protected]
           └─init.scope
             ├─549 /usr/lib/systemd/systemd --user
             └─551 "(sd-pam)"

~
❯ 

Attached log contains journalctl output in this boot.

journalctl_2025-06-06.log

gasuketsu avatar Jun 06 '25 15:06 gasuketsu

I'm facing a very similar problem but with CentOS7-9 distro but I can't recover even after issuing sudo systemctl restart [email protected] as @gasuketsu.

$ systemctl --user status
Failed to get D-Bus connection: No such file or directory

$ ls -l /run/user
total 0
drwxr-xr-x 4 root   root   120 Jun  6 11:13 0
drwxr-xr-x 4 dluong dluong 120 Jun  6 11:14 1000
[dluong@dluong-dt11_el7 /run/user]$ ls -l /run/user/1000
total 0
drwxr-xr-x 3 dluong dluong 60 Jun  6 11:14 dbus-1
drwxr-xr-x 2 dluong dluong 80 Jun  6 11:14 pulse
lrwxrwxrwx 1 root   root   31 Jun  6 11:14 wayland-0 -> /mnt/wslg/runtime-dir/wayland-0
lrwxrwxrwx 1 root   root   36 Jun  6 11:14 wayland-0.lock -> /mnt/wslg/runtime-dir/wayland-0.lock

$ sudo systemctl restart [email protected]
Failed to get D-Bus connection: No such file or directory
PS> wsl --version

WSL version: 2.5.7.0
Kernel version: 6.6.87.1-1
WSLg version: 1.0.66
MSRDC version: 1.2.6074
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26100.1-240331-1435.ge-release
Windows version: 10.0.26100.4061

I have two distros but it seems to only affect CentOS7-9! I know this was working fine on 5/1/2025 but I don't recall the wsl version.

wsl --list
Windows Subsystem for Linux Distributions:
CentOS7-9 (Default)
RockyLinux6.3
$ systemctl --user status
● dluong-dt11
    State: running
    Units: 164 loaded (incl. loaded aliases)
     Jobs: 0 queued
   Failed: 0 units
    Since: Fri 2025-06-06 10:20:12 CDT; 31min ago
  systemd: 252-18.el9.0.1.rocky
   CGroup: /user.slice/user-1000.slice/[email protected]
           └─init.scope
             ├─142 /usr/lib/systemd/systemd --user
             └─143 "(sd-pam)"

dluongiop avatar Jun 06 '25 16:06 dluongiop

Found that this issue is not reproduced by disabling guiApplications (i.e. guiApplications=false in .wslconfig). Something like race condition with WSLg related service(s) ?

gasuketsu avatar Jun 06 '25 23:06 gasuketsu

I found that I have same condition with following comment. (I also have loginctl enable-linger $UID for my account) https://github.com/microsoft/WSL/issues/10205#issuecomment-2931121662

gasuketsu avatar Jun 08 '25 07:06 gasuketsu

s. https://github.com/microsoft/WSL/issues/13053

pfeileon avatar Jun 23 '25 11:06 pfeileon

Perhaps it is related to this issue, specifically in the way wslg remounts certain folders: https://github.com/microsoft/WSL/issues/12989

W1M0R avatar Jul 10 '25 14:07 W1M0R

Fixed in 2.6.0. Feel free to open a new issue if you're still hitting problems with systemd user sessions.

OneBlue avatar Jul 10 '25 17:07 OneBlue