microsoft / wslg

Enabling the Windows Subsystem for Linux to include support for Wayland and X server related scenarios
MIT License
9.9k stars 296 forks source link

Pulseaudio - Too many levels of symbolic links #1220

Closed crisperit closed 2 months ago

crisperit commented 3 months ago

Windows build number:

10.0.22631.3374

Your Distribution version:

22.04

Your WSL versions:

WSL version: 2.1.5.0
Kernel version: 5.15.146.1-2
WSLg version: 1.0.60
MSRDC version: 1.2.5105
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22631.3374

Steps to reproduce:

I'm just calling pulseaudio in the terminal which results in

W: [pulseaudio] pid.c: Failed to open PID file '/run/user/1000/pulse/pid': Too many levels of symbolic links
E: [pulseaudio] main.c: Failed to kill daemon: Too many levels of symbolic links

WSL logs:

weston.log pulseaudio.log stderr.log

WSL dumps:

No response

Expected behavior:

Pulseaudio opens and it is possible to hear the sound out of the WSL apps like Firefox

Actual behavior:

❯ pulseaudio
W: [pulseaudio] pid.c: Failed to open PID file '/run/user/1000/pulse/pid': Too many levels of symbolic links
E: [pulseaudio] main.c: pa_pid_file_create() failed.
❯ ls -al /run/user/1000/pulse/pid
lrwxrwxrwx 1 root root 31 Mar 28 17:07 /run/user/1000/pulse/pid -> /mnt/wslg/runtime-dir/pulse/pid
❯ ls -al /mnt/wslg/runtime-dir/pulse/pid
-rw------- 1 user user 5 Mar 28 17:07 /mnt/wslg/runtime-dir/pulse/pid

❯ systemctl --user status pulseaudio.socket
× pulseaudio.socket - Sound System
     Loaded: loaded (/usr/lib/systemd/user/pulseaudio.socket; enabled; vendor preset: enabled)
     Active: failed (Result: service-start-limit-hit) since Thu 2024-03-28 17:07:24 CET; 7min ago
   Triggers: ● pulseaudio.service
     Listen: /run/user/1000/pulse/native (Stream)

Mar 28 17:07:22 User systemd[594]: Listening on Sound System.
Mar 28 17:07:24 User systemd[594]: pulseaudio.socket: Failed with result 'service-start-limit-hit'.

In a fresh installation which I've done through Microsoft Store I believe the sound was working - not sure what has changed that valid behavior

viruscamp commented 2 months ago

Actually, you donot need starting pulseaudio to hear the sound.

There is one pulseaudio running in WSL system distro, and having export a pulse socket as /mnt/wslg/PulseServer, just use that.

You can check the env vars and files:

$ env | grep -E "PULSE|XDG"
XDG_RUNTIME_DIR=/run/user/1000/
PULSE_SERVER=unix:/mnt/wslg/PulseServer

$ ls -l /mnt/wslg/PulseServer
srwxrwxrwx 1 user1 user1 0  4-12 22:36 /mnt/wslg/PulseServer

$ ls -l  /run/user/1000/pulse/
lrwxrwxrwx 1 user1 user1 34  4-12 22:36 native -> /mnt/wslg/runtime-dir/pulse/native
lrwxrwxrwx 1 user1 user1 31  4-12 22:36 pid -> /mnt/wslg/runtime-dir/pulse/pid
crisperit commented 2 months ago

Ok - right it seems that pulseaudio installation on mine Ubuntu22 distro has overwritten the symbolic link for /run/user/1000/pulse/native

I've removed pulseaudio via

sudo apt-get remove pulseaudio  

Then I've restarted the WSL via

wsl --shutdown

And finally I've added the missing symbolic link

sudo ln -f -s /mnt/wslg/runtime-dir/pulse/native /run/user/1000/pulse/native

Now all works fine - thanks @viruscamp!

viruscamp commented 2 months ago
sudo ln -f -s /mnt/wslg/runtime-dir/pulse/native /run/user/1000/pulse/native

You should not use sudo