-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Windows Version
10.0.19044.4046
WSL Version
2.0.14.0
Are you using WSL 1 or WSL 2?
- WSL 2
- WSL 1
Kernel Version
5.15.133.1-1
Distro Version
Arch
Other Software
- wl-clipboard 2.2.1 (shouldn't be the root cause)
- systemd 255.4-2
Repro Steps
- Install
wl-clipboard->sudo pacman -S wl-clipboard - Run
echo "foobar" | wl-copy
Expected Behavior
foobar is copied to Windows clipboard through Wayland
Actual Behavior
❯ echo "foobar" | wl-copy
Failed to connect to a Wayland server: No such file or directory
Note: WAYLAND_DISPLAY is set to wayland-0
Note: XDG_RUNTIME_DIR is set to /run/user/1000/
Please check whether /run/user/1000//wayland-0 socket exists and is accessible.Diagnostic Logs
Not applicable
Additional Note
I couldn't open any GUI apps and any Wayland-related tools such as wl-copy.
❯ echo "foobar" | wl-copy
Failed to connect to a Wayland server: No such file or directory
Note: WAYLAND_DISPLAY is set to wayland-0
Note: XDG_RUNTIME_DIR is set to /run/user/1000/
Please check whether /run/user/1000//wayland-0 socket exists and is accessible.The following are the content of /run/user/1000/
❯ ls -la /run/user/1000/
total 0
drwx------ 7 mangkoran mangkoran 220 Mar 7 08:38 ./
drwxr-xr-x 3 root root 60 Mar 7 08:34 ../
srw-rw-rw- 1 mangkoran mangkoran 0 Mar 7 08:34 bus=
prw------- 1 mangkoran mangkoran 0 Mar 7 08:34 fish_universal_variables.notifier|
drwx------ 2 mangkoran mangkoran 60 Mar 7 08:34 gcr/
drwx------ 2 mangkoran mangkoran 160 Mar 7 08:34 gnupg/
drwxr-xr-x 2 mangkoran mangkoran 60 Mar 7 08:34 p11-kit/
srw-rw-rw- 1 mangkoran mangkoran 0 Mar 7 08:34 pipewire-0=
srw-rw-rw- 1 mangkoran mangkoran 0 Mar 7 08:34 pipewire-0-manager=
drwxr-xr-x 2 mangkoran mangkoran 60 Mar 7 08:34 pulse/
drwxr-xr-x 6 mangkoran mangkoran 160 Mar 7 08:34 systemd/Based on that it seems wayland-0 socket is missing in XDG_RUNTIME_DIR. Hmm pretty weird I think as I don't disable guiApplications in .wslconfig.
Then I found microsoft/wslg#1187. I proceed to check /mnt/wslg/runtime-dir/.
❯ ls -la /mnt/wslg/runtime-dir/
total 0
drwx------ 4 mangkoran mangkoran 120 Mar 7 09:24 ./
drwxrwxrwt 8 root root 320 Mar 7 08:34 ../
drwx------ 3 mangkoran mangkoran 60 Mar 7 08:34 dbus-1/
drwx------ 2 mangkoran mangkoran 80 Mar 7 08:34 pulse/
srwxrwxrwx 1 mangkoran mangkoran 0 Mar 7 08:34 wayland-0=
-rw-rw---- 1 mangkoran mangkoran 0 Mar 7 08:34 wayland-0.lockAnd yep there it is. So Wayland socket is currently not in XDG_RUNTIME_DIR. It seems the Wayland socket was previously symlinked in XDG_RUNTIME_DIR as in #10205. Then I tried to link the Wayland socket.
~
❯ ln -s /mnt/wslg/runtime-dir/wayland-0* /run/user/1000/
~
❯ echo "foobar" | wl-copy
~
❯ echo $status
0Although it works as intended, I think this isn't the default behavior/a regression.
Workaround
As a workaround, I created a simple systemd user oneshot service/unit.
❯ cat ~/.config/systemd/user/symlink-wayland-socket.service
[Unit]
Description=Symlink Wayland socket to XDG_RUNTIME_DIR
[Service]
Type=oneshot
ExecStart=/usr/bin/ln -s /mnt/wslg/runtime-dir/wayland-0 $XDG_RUNTIME_DIR
ExecStart=/usr/bin/ln -s /mnt/wslg/runtime-dir/wayland-0.lock $XDG_RUNTIME_DIR
[Install]
WantedBy=default.targetEnable it using the following command.
systemctl --user enable symlink-wayland-socket.serviceTip
For Ubuntu 24.04 user, please refer to additional workaround by @noopole #11261 (comment)
Fix
Fixed in https://github.com/microsoft/WSL/releases/tag/2.5.1
Refs: #11261 (comment)