Skip to content

"bwrap: can't make symlink at /var/run: File exists" when /media is a symlink to /var/run/media #3477

Closed

Description

@tallero

Linux distribution and version

Archlinux, Builder v3.36.0, 3.34, 3.32

Flatpak version

1.6.2

Description of the problem

When I try to run to run any project in (distro's) Builder I do get after correctly building the app

Application started at 04:59:29 AM
bwrap: Can't make symlink at /var/run: File exists
Application exited

It happened through 3.34 branch and even on 3.32 but at the time it went away with

systemctl start --user xdg-desktop-portal

bwrap file exists

If I try to run flatpak'd Builder instead, I do get

➜  Projects flatpak --verbose run org.gnome.Builder
F: No installations directory in /etc/flatpak/installations.d. Skipping
F: Opening system flatpak installation at path /var/lib/flatpak
F: Opening user flatpak installation at path /home/user/.local/share/flatpak
F: Opening user flatpak installation at path /home/user/.local/share/flatpak
F: Opening system flatpak installation at path /var/lib/flatpak
F: Opening user flatpak installation at path /home/user/.local/share/flatpak
F: Opening system flatpak installation at path /var/lib/flatpak
F: Cleaning up unused container id 2123384349
F: Allocated instance id 2731448443
F: Add values in dir '/org/gnome/builder/', prefix is '/org/gnome/Builder/'
F: Add defaults in dir /org/gnome/Builder/
F: Add locks in dir /org/gnome/Builder/
F: writing D-Conf values to /home/user/.var/app/org.gnome.Builder/config/glib-2.0/settings/keyfile
F: Allowing dri access
F: Allowing host-fs access
F: Allowing homedir access
F: Allowing wayland access
F: Allowing x11 access
F: Allowing session-dbus access
F: Allowing system-dbus access
F: Running 'bwrap --args 27 xdg-dbus-proxy --args=33'
F: Running 'bwrap --args 30 gnome-builder'
bwrap: Can't make symlink at /var/run: File exists

Steps to reproduce

  1. Create a new GNOME application in GNOME Builder (any language)
  2. Click on run

Maybe something is wrong in my /var. Do you know where should I look?

References

Activity

  1. probonopd commented on Mar 22, 2020

    @probonopd

    Even without GNOME Buidler, I've been running into the same issue since basically forever (preventing me from testing Flatpak on Ubuntu Live ISOs). E.g., on the Xubuntu 18.04.2 LTS Live ISO:

    me@host:~$ flatpak --version
    Flatpak 1.6.2 # from PPA
    
    me@host:~$ flatpak run --user --command=bash org.gnome.gedit
    
    Note that the directories 
    
    '/var/lib/flatpak/exports/share'
    '/home/me/.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 make symlink at /var/run: File exists
    
  2. tallero commented on Mar 23, 2020

    @tallero
    Author

    @probonopd Did you try with systemctl --user start xdg-desktop-portal?

  3. probonopd commented on Mar 24, 2020

    @probonopd

    Originally I hadn't, but even if I do, the result is the same. Thanks @tallero

  4. tallero commented on Mar 25, 2020

    @tallero
    Author

    I am sorry. On 18.04's GNOME release that solved the bug for me at the time.

  5. tallero commented on Jun 5, 2020

    @tallero
    Author

    Temporarly moving /var/run solves the problem, but isn't it created at boot?

  6. probonopd commented on Jun 6, 2020

    @probonopd

    E.g., on Xubuntu Bionic Live ISO:

    me@host:~$ ls -lh  /var/run
    lrwxrwxrwx 1 root root 4 Feb  3 19:22 /var/run -> /run
    
    me@host:~$ mount | grep "on /run"
    tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
    tmpfs on /run/user/999 type tmpfs (rw,nosuid,nodev,relatime,size=1007308k,mode=700,uid=999,gid=999)
    gvfsd-fuse on /run/user/999/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=999,group_id=999)
    
  7. Yiannis128 commented on Mar 17, 2021

    @Yiannis128

    Running into this issue as well...

    Also FYI for anyone following advice about messing with /var/run, don't it will cause your system to not boot because GDM needs NetworkManager and NetworkManager relies on that symlink.

  8. tallero commented on Mar 17, 2021

    @tallero
    Author

    @Yiannis128 wait I said temporarily

  9. Yiannis128 commented on Mar 17, 2021

    @Yiannis128

    @tallero Yeah, in hindsight I can see that what you said is correct, the issue is that I didn't know that it was "temporarily as in move it back or you soft brick your OS", I decided to let other people know by making it extra clear :) Also, while it does fix some apps like Gnome Builder not launching, it breaks NetworkManager, so working on apps like Gnome Web is impossible without directly solving this issue.

  10. tallero commented on Mar 18, 2021

    @tallero
    Author

    Yes, I specified it because an year ago I've temporarily broken my system, too.

  11. smcv commented on Mar 18, 2021

    @smcv
    Collaborator

    Running the org.gnome.Builder Flatpak app works fine for me (with Flatpak 1.10.2 on Debian 11).

    Do you have any Flatpak permissions overrides, either for GNOME Builder or globally? I suspect this can be triggered by sharing more filesystems with the app. Try:

    $ flatpak override --show
    $ flatpak override --show org.gnome.Builder
    $ flatpak override --user --show
    $ flatpak override --user --show org.gnome.Builder
    

    Also try running flatpak run -vv (-vv instead of --verbose) which would show the full bubblewrap command-line.

    Also FYI for anyone following advice about messing with /var/run, don't

    Certainly don't remove /var/run, it's a necessary part of the OS. On most Linux distributions the expected situation is that you have a symlink /var/run -> /run and a tmpfs on /run.

  12. smcv commented on Mar 18, 2021

    @smcv
    Collaborator

    @Yiannis128, you haven't said what version of Flatpak you are using, or which operating system you are using?

  13. Yiannis128 commented on Mar 18, 2021

    @Yiannis128

    @smcv I'm using Manjaro running kernel 5.11.2-1-MANJARO. For Flatpak I have version 1.10.1 installed.

  14. Yiannis128 commented on Mar 18, 2021

    @Yiannis128

    Running the org.gnome.Builder Flatpak app works fine for me (with Flatpak 1.10.2 on Debian 11).

    Do you have any Flatpak permissions overrides, either for GNOME Builder or globally? I suspect this can be triggered by sharing more filesystems with the app. Try:

    $ flatpak override --show
    $ flatpak override --show org.gnome.Builder
    $ flatpak override --user --show
    $ flatpak override --user --show org.gnome.Builder
    

    Also try running flatpak run -vv (-vv instead of --verbose) which would show the full bubblewrap command-line.

    Also FYI for anyone following advice about messing with /var/run, don't

    Certainly don't remove /var/run, it's a necessary part of the OS. On most Linux distributions the expected situation is that you have a symlink /var/run -> /run and a tmpfs on /run.

    I don't know what Flatpak permission overrides are so I assume I don't have any...

    Here is the output of each of the requested commands

    image

    Here is the output of the -vv run command, it's big so I dumped it at TextBin:
    https://textbin.net/rn8aclzcvb

  15. smcv commented on Mar 18, 2021

    @smcv
    Collaborator

    This is correct:

    --symlink ../run /var/run
    

    but then, later, this also appears in the command-line:

    --symlink ../var/../run /var/run
    

    and I think that might be what is breaking it for you.

    It looks as though your /media is a symbolic link to /var/run/media.

    If you change that to be a symbolic link to /run/media, does that help?

  16. 9 remaining items

  17. mirkobrombin commented on Jan 12, 2023

    @mirkobrombin

    Thanks for the detailed answer. I fixed it by binding the path /var instead of using a symlink.

  18. smcv commented on Jan 12, 2023

    @smcv
    Collaborator

    I'm facing the same issue in a setup where /var is a symlink of /.system/var.

    #5213 might help with that, actually.

    I fixed it by binding the path /var instead of using a symlink

    I would always recommend using mount points rather than symlinks for this sort of OS-level filesystem aliasing, where the existence of /.system is (presumably) an implementation detail and you still want /var to be treated as the canonical path.

  19. smcv commented on Jan 12, 2023

    @smcv
    Collaborator

    @tallero: Was this symptom caused for you by the same setup that @Yiannis128 reported (/media a symlink to /var/run/media)?

    If not, please provide the information I asked for in #3477 (comment), similar to #3477 (comment).

  20. mirkobrombin commented on Jan 12, 2023

    @mirkobrombin

    I would always recommend using mount points rather than symlinks for this sort of OS-level filesystem aliasing, where the existence of /.system is (presumably) an implementation detail and you still want /var to be treated as the canonical path.

    I figured it out the hard way.

  21. deftdawg commented on Jan 18, 2023

    @deftdawg

    I overrode /var/run/docker.sock with a link to the host and now my flatpak won't start because it already exists and I can find no way of removing the override...

    How in do I nuke the override? Flatseal couldn't reset, even uninstalling the flatpak doesn't reset it...

    flatpak override --show com.visualstudio.code
    [Context]
    filesystems=/var/run/docker.sock;/run/docker.sock;
    

    (this is with the flatpak no longer installed)

  22. smcv commented on Jan 18, 2023

    @smcv
    Collaborator

    I overrode /var/run/docker.sock

    This is off-topic in this issue report, despite the similar error message, because this issue report is specifically about /media being a symlink to /var/run/media. I'm trying to keep to 1 issue = 1 report, to reduce confusion and avoid having issue reports that can never be closed because nobody knows whether all their root causes have been dealt with.

    To remove filesystems=/var/run/docker.sock;/run/docker.sock; overrides, use:

    flatpak override --nofilesystem=/run/docker.sock --nofilesystem=/var/run/docker.sock com.visualstudio.code
    

    The four possible sources of overrides are:

    1. flatpak override ... com.example.app will add or remove overrides in /var/lib/flatpak/overrides/com.example.app
    2. flatpak override --user ... com.example.app will add or remove overrides in ~/.local/share/flatpak/overrides/com.example.app
    3. flatpak override ... without an app ID will add or remove overrides in /var/lib/flatpak/overrides/global
    4. flatpak override --user ... without an app ID will add or remove overrides in ~/.local/share/flatpak/overrides/global

    For each of those four types of override, you can use flatpak override --show (with or without an app ID, and with or without --user) to show the overrides that exist.

  23. deftdawg commented on Jan 18, 2023

    @deftdawg

    Thank you, this helped me find the flatpak overrides were in /var/lib/flatpak/overrides, I ended up doing sudo rm /var/lib/flatpak/overrides/com.visualstudio.code to reset the package overrides (the --nofilesystem override explicitly excluded the files with ! prefix which inverts the override but doesn't remove it)

  24. added a commit that references this issue on Mar 27, 2024
  25. added a commit that references this issue on Mar 27, 2024
  26. ell1e commented on Sep 22, 2024

    @ell1e

    Is this meant to work with flatpak 1.14.10? I still can't start any flatpak app if it mounts a folder ~/GOG Games/ (as Minigalaxy does with its manifest) and that folder happens to be a symlink to somewhere else.

    $ flatpak run io.github.sharkwouter.Minigalaxy
    bwrap: Can't make symlink at /home/user/GOG Games: destination exists and is not a symlink
    $ flatpak --version
    Flatpak 1.14.10
    
  27. smcv commented on Sep 23, 2024

    @smcv
    Collaborator

    bwrap: Can't make symlink at /home/user/GOG Games: destination exists and is not a symlink

    You'll notice that this is not the same message as in the issue title.

    You probably have a non-symlink (presumably a directory) in ~/.var/app/io.github.sharkwouter.Minigalaxy/GOG Games. bubblewrap cannot tell what you want to happen in this situation, so it defaults to "report an error and let the user sort it out".

    The manifest for Minigalaxy has:

      - --filesystem=~/GOG Games:create
      - --persist=.
    

    which means:

    • the "real" ~/GOG Games in my real home directory is required to be shared with the app
      • if it's a symlink, then Flatpak shares the symlink target with the app and creates the same symlink in the app's sandbox, to make this part of the sandbox's home directory as similar as possible to the corresponding part of the "real" filesystem
    • but also, I want everything in the sandbox's home directory to "persist", so the symlink/directory status of every file and directory in the sandbox's ~ will remain the same from one run to the next

    This means that if the symlink/directory status of ~/GOG Games in your "real" home directory is not consistent with the symlink/directory status of ~/GOG Games in the sandbox's home directory ~/.var/app/io.github.sharkwouter.Minigalaxy, you will get an error.

    The solution is to make ~/.var/app/io.github.sharkwouter.Minigalaxy/GOG Games consistent with ~/GOG Games, for example by removing an empty directory so that Flatpak can create a symlink in its place.

    In principle it would be possible for Flatpak to detect that a path already exists in a --persist directory and therefore can only be created in a way that is consistent with what's already there; this could be reported as a separate feature request with steps to reproduce the issue, if you want. But the interactions between --persist and --filesystem are not simple, so it's relatively likely that it will only be resolved if someone from the community steps forward to figure out how it can be achieved and propose a PR.

  28. ell1e commented on Sep 23, 2024

    @ell1e

    Thanks so much for the response! I confirm that inner directory was present, and removing it fixed the problem. Some unqualified speculation of mine as to what happened: I don't think I created that directory, so the fix for this issue seems potentially somewhat ineffective if in practice something from flathub can create this inner directory, then result in later if a symlink is put in place by the user for it to not work. I'm guessing the problem is that I didn't do it before launching the app for the first time but at some later point, but that's not something the average user is going to be aware of. If that is correct, it would be nice if this could be addressed for the cases where the inner directory that the user didn't manually create is indeed completely empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions