Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flatpak cannot be used normally after the built-in Systemd support is enabled #9119

Closed
1 of 2 tasks
linghengqian opened this issue Nov 5, 2022 · 4 comments
Closed
1 of 2 tasks

Comments

@linghengqian
Copy link

Version

Microsoft Windows [版本 10.0.22621.755]

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.15.68.1

Distro Version

Ubuntu 22.04

Other Software

chromium, version 107.0.5304.87 . Refer to https://flathub.org/apps/details/org.chromium.Chromium .

Repro Steps

sudo apt update && sudo apt upgrade -y
sudo apt install flatpak
sudo apt install gnome-software-plugin-flatpak
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
sudo flatpak install flathub org.chromium.Chromium
  • Open the application with the following two commands, and we can see the log.
flatpak run org.chromium.Chromium

Expected Behavior

  • Normal Started.

Actual Behavior

  • When executing flatpak run org.chromium.Chromium, I saw some error and unable to start the application normally.
lingh@DESKTOP-TPTE5D5:~$ flatpak run org.chromium.Chromium

Note that the directories

'/var/lib/flatpak/exports/share'
'/home/lingh/.local/share/flatpak/exports/share'

are not in the search path set by the XDG_DATA_DIRS environment variable, so
applications installed by Flatpak may not appear on your desktop until the
session is restarted.

bwrap: Can't mount tmpfs on /newroot/dev/shm: No such file or directory
  • image

  • If I execute sudo flatpak run org.chromium.Chromium, I will see another error log.

lingh@DESKTOP-TPTE5D5:~$ sudo flatpak run org.chromium.Chromium
error: "flatpak run" is not intended to be run as `sudo flatpak run`, use `sudo -i` or `su -l` instead and invoke "flatpak run" from inside the new shell

Diagnostic Logs

  • Null.
@cerebrate
Copy link

This may be related to your #9118, insofar as flatpak, at least for me, uses a user systemd service (flatpak-session-helper.service).

Another possibility that might be worth looking into is that it might be related to the setup of /dev/shm and /run/shm under WSL, in which by default the private shared memory tmpfs is mounted at /run/shm and /dev/shm is a symbolic link to it, rather than the other way around, which is the normal arrangement when running under systemd. If so, reversing this with something like this systemd service unit:

[Unit]
Description=bottle-imp - Fix the /dev/shm symlink to be a mount
DefaultDependencies=no
Before=sysinit.target
ConditionPathExists=/dev/shm
ConditionPathIsSymbolicLink=/dev/shm
ConditionPathIsMountPoint=/run/shm

[Service]
Type=oneshot
ExecStart=/usr/bin/rm /dev/shm
ExecStart=/usr/bin/mkdir /dev/shm
ExecStart=/bin/umount /run/shm
ExecStart=/usr/bin/rmdir /run/shm
ExecStart=/bin/mount -t tmpfs -o mode=1777,nosuid,nodev,strictatime tmpfs /dev/shm
ExecStart=/usr/bin/ln -s /dev/shm /run/shm

[Install]
WantedBy=sysinit.target

may get it up and running.

I can confirm that flatpak can be made to work under WSL, so one of these fixes seems likely to be the needful.

@linghengqian
Copy link
Author

@cerebrate
Copy link

This surprised me a bit, as I don't think this should be actively handled by the user.

No argument there, but systemd support under WSL is still in the early days. There are issues open here for both of these problems specifically, the user sessions/dbus at #8842 and the /dev/shm issue at #8996, FYI.

@linghengqian
Copy link
Author

linghengqian commented Aug 10, 2023

  • On Ubuntu-Preview WSL, i.e. Ubuntu 23.10, the flatpak application Firefox is ready to open and use. I'm going to close this issue, as most of the issues now only need to be handled in the app itself. The following bash command can be verified under the new Ubuntu-Preview WSL instance.
sudo apt update && sudo apt upgrade -y
sudo apt install gnome-text-editor gimp vlc nautilus x11-apps -y
sudo apt install flatpak
sudo flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
sudo flatpak install flathub org.mozilla.firefox
flatpak run org.mozilla.firefox
  • image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants