Skip to content

Flatpak gets confused where symlinks will end up #1658

Closed

Description

@jurf

(And frankly, so do I. Sorry @alexlarsson, we both tried our best.)

Linux distribution and version

Fedora 28

Flatpak version

0.11.3

Description of the problem

Originally reported and described in flathub/com.valvesoftware.Steam#66.

Steps to reproduce

$ ln -s /opt ~/symlink
$ flatpak run --filesystem=~/symlink com.valvesoftware.Steam 
... exit it
$ flatpak run --filesystem=~/symlink com.valvesoftware.Steam 
bwrap: Can't make symlink at /home/alex/symlink: File exists

Activity

  1. nanonyme commented on Aug 9, 2018

    @nanonyme
    Contributor

    Out of curiosity, what would the end result here be if you ignored the error from bwrap?

  2. nanonyme commented on Aug 15, 2018

    @nanonyme
    Contributor

    @alexlarsson isn't the end goal here that the persist wouldn't affect things defined through filesystem since you can define things read-only through filesystem? Or did I still not get the full picture?

  3. Mange commented on Jan 3, 2019

    @Mange

    The fact that it works on first boot and then fails to work hints that the problem might be this:

    bwrap checks if the file exists (which it doesn't as the symlink is broken) and then tries to create the symlink there which doesn't work as the file actually exists.

    Maybe if the "file exists" check used lstat instead of stat-like functions, then it would work?

    (This is just a guess, but I've been bitten by this exact problem in my own software a few times.)

    [EDIT]: I've managed to disprove my hypothesis, because I managed to fix the symlink so it worked on my system but the problem persists.

  4. dustymabe commented on Oct 20, 2020

    @dustymabe

    I hit this issue when running steam and stumbled across the entry in the FAQ that pointed me here.

    I was using a per-user installation of flatpak and was able to workaround by doing something like:

    FLATPAK_USER_DIR=$(readlink -f ~/.local/share/flatpak) flatpak --user run com.valvesoftware.Steam
    

    You can make a wrapper in /usr/local/bin/steam if you want so you don't have to do it every time:

    #!/bin/bash
    FLATPAK_USER_DIR=$(readlink -f ~/.local/share/flatpak) exec flatpak --user run com.valvesoftware.Steam $@
    

    If you are using the system installation I assume the same would work by setting the FLATPAK_SYSTEM_DIR var.

  5. WhyNotHugo commented on Dec 3, 2020

    @WhyNotHugo

    I'm getting this error too (and was also pointed here by the FAQ).

    However, I can't make heads or tails of the errors:

    $ flatpak run com.valvesoftware.Steam
    bwrap: Can't make symlink at /home/hugo/.config: File exists

    However, steam does not have access to my $HOME, nor $HOME/.config. Actually, it has access to no filesystem directories.

    $ cat ~/.local/share/flatpak/overrides/com.valvesoftware.Steam
    [Context]
    filesystems=!xdg-music:ro;!xdg-pictures:ro

    Any hints on what's up?

  6. YaLTeR commented on Mar 31, 2021

    @YaLTeR

    Also hitting this. I reinstalled my system and replaced a few folders in ~ with symlinks to another storage device. I need to share one of those folders with the Steam flatpak, and now I can't properly do that because flatpak copies over the symlink to ~/.var/app/com.valvesoftware.Steam and then fails to clean it up after exiting.

  7. smcv commented on Mar 31, 2021

    @smcv
    Collaborator

    A general workaround for most weird issues with symlinks is to prefer to use bind-mounts instead of symlinks.

    Apps that aren't Steam often don't have this problem. Steam is special because any Steam game might try to write to any location, so the Steam Flatpak app uses --persist=. to make all of ~/.var/app/com.valvesoftware.Steam available as a persistent directory in the sandbox.

    It's entirely possible that different people who are reporting this are seeing different root causes, and I suspect that a solution to any of them will require changes to bubblewrap - something along the lines of "don't treat failure to create a symlink as fatal if it already points to the same place we want it to".

    The output from flatpak run -vv com.valvesoftware.Steam would probably be helpful to debug this.

  8. gregzme17 commented on May 29, 2022

    @gregzme17

    I am still experiencing this issue with Linux Mint 20.3, Steam flatpak.
    4 of my user directories are symlink to my NAS which is mounted with fstab using nfs protocol.
    I am still working on a good workaround, because changing the XDG dirs seems to cause me a lot of problems with the NAS mounting correctly.
    Output requested by @smcv
    output-flatpak-Steam.txt

  9. RossComputerGuy commented on Oct 24, 2022

    @RossComputerGuy

    I have global overrides where ~/.nix-profile is added which is a symlink of /nix/store/3w25fy7fpsb2s0q46qcf799x9y5d82zv-user-environment which changes every time nixos-rebuild switch. I disabled the override in Flatseal and Steam still wants to symlink ~/.nix-profile. Is there any solution?

  10. rpdelaney commented on Jul 4, 2023

    @rpdelaney

    I'm also affected:

    $ flatpak run com.valvesoftware.Steam
    
    bwrap: Can't make symlink at /home/ryan/media: File exists
    $
    Details
    F: Trying to replace with tmpfs: /home/ryan/media/audio
    F: /home/ryan/media is a symlink, resolved to /media
    F: Trying to export the target instead: /media/audio
    F: Trying to replace with tmpfs: /media/audio
    F: /media is not a symlink
    F: /media/audio is not a symlink
    F: Will replace with tmpfs: /media/audio
    F: Will create symbolic link: /home/ryan/media
    F: "/home/ryan/media" is meant to be a symlink
    F: Resolved "/home/ryan/media" to "/media" in host
    F: Creating "/home/ryan/media" -> "../../media" in sandbox
    F: "/media/audio" is meant to be a tmpfs or empty directory
    F: Parent of "/media/audio" is not mapped, creating empty directory
    :F:     /media
    :F:     /media
    :F:     ../../media
    :F:     /home/ryan/media
    :F:     /media/audio
    :F:     /home/ryan/media/incoming
    9:bwrap: Can't make symlink at /home/ryan/media: File exists
    

    "Don't have symlinks" is not a useful answer. Flatpak is supposed to be isolated from my home directory. Why is this package trying to mess with creating symlinks here at all?

  11. nanonyme commented on Jul 4, 2023

    @nanonyme
    Contributor

    Because that is the only way Steam Cloud can work inside the app for all games including ones that support xdg spec and ones that don't without crashes.

  12. nanonyme commented on Jul 4, 2023

    @nanonyme
    Contributor

    It does not create symlinks inside your home but under a virtual home.

  13. rpdelaney commented on Jul 4, 2023

    @rpdelaney

    something along the lines of "don't treat failure to create a symlink as fatal if it already points to the same place we want it to".

    This sounds like a good solution.

  14. CendioOssman commented on Dec 15, 2023

    @CendioOssman

    Any progress on this? I'm getting hit by a variation of this as well trying to run flatpaks, as I have symlinks to redirect my XDG directories per-machine (to avoid them overwriting each others data):

    bwrap: Can't make symlink at /run/user/4051/confredir/local: File exists
    
  15. toupeira commented on Feb 17, 2024

    @toupeira

    Looks like this was now fixed in bwrap and should make it into the next release: containers/bubblewrap#577

  16. chrisawi commented on Mar 19, 2024

    @chrisawi
    Collaborator

    @smcv Can we close this now or do you want to keep it open until a bubblewrap release?

    The same goes for the other issues you listed in containers/bubblewrap#549 (comment) (after verifying that they're fixed).

  17. smcv commented on Mar 19, 2024

    @smcv
    Collaborator

    Can we close this now or do you want to keep it open until a bubblewrap release?

    I think it would make most sense to keep this open until we have a bubblewrap release, and then update Flatpak's bundled bubblewrap to that version and close this issue (and the others) at that time.

  18. chrisawi commented on Mar 27, 2024

    @chrisawi
    Collaborator

    Fixed in bubblewrap 0.9.0

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions