microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.41k stars 822 forks source link

When running Snapd programs with built-in Systemd support, there is some Waring about D-Bus session daemon #9118

Closed linghengqian closed 1 year ago

linghengqian commented 1 year ago

Version

Microsoft Windows [版本 10.0.22621.755]

WSL Version

Kernel Version

5.15.68.1

Distro Version

Ubuntu 22.04

Other Software

vlc, version 3.0.18 . Refer to https://snapcraft.io/vlc . gnome-text-editor, version 42.2 . Refer to https://snapcraft.io/gnome-text-editor .

Repro Steps

Expected Behavior

Actual Behavior

(process:1852): Gdk-WARNING **: 11:03:06.028: Settings portal not found: 无法连接:No such file or directory Gdk-Message: 11:03:06.322: Failed to get file transfer portal: 无法连接:No such file or directory


- ![image](https://user-images.githubusercontent.com/20187731/200098193-7050a05b-b765-4ddf-af05-4ab8b814fd3d.png)

### Diagnostic Logs

- Null.
cerebrate commented 1 year ago

This is #8842 ; the quick answer is that the way wsl.exe creates Linux-side processes doesn't go through PAM, so a user login session is never set up, so a user systemd instance is never started, so a user dbus is never created.

(There are various workarounds for this. Mine is bottle-imp, which I'm mentioning here because there are also several gotchas to implementing functioning user-login-session support which it fixes, and it would take a long time to explain them all.

...WSL team, I hope it's not too bad form to advertise my own solution like this, but...)

linghengqian commented 1 year ago
sbroberg commented 1 year ago

@cerebrate: You mention that bottle-imp is a workaround. How do you use it to fix the problem? I've installed it according to the instructions on your link, but I'm not sure to do with it once it's installed - the README is a bit inscrutable to someone with my understanding of what systemd is doing. I ran "imp -i", but all the other commands just produce an error that says "imp: cannot launch command; systemd-machined is not active".

cerebrate commented 1 year ago

@sbroberg

Which distro are you using?

bottle-imp uses systemd-machined (apt package name: systemd-containerd for some reason) to start user sessions when you use one of the -s/-c/-l options (and thus ensure that all the PAM/systemd session initialization is done correctly). That error message is the one you get if systemd-machined is somehow not enabled - despite bottle-imp doing so at runtime - or not installed, which the (Debian/Arch) packaged versions of bottle-imp should do automatically.

You can check the state of the service with

systemctl status systemd-machined

If it's not installed/can't be found, installing it should solve your problem. If it's something weirder, please open an issue over at the bottle-imp repo, and I'll see what I can do.

linghengqian commented 1 year ago