You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: bwrap: Can't make symlink at /var/run: File exists, involving /var/run/media #5255
As I tried to indicate on [edit: #2710], we are not going to be able to magically solve this without more information, so please provide the output of flatpak run -v -v org.freecadweb.FreeCAD (or any other app that shows the same symptom, the simpler the better). For what it's worth, I can't reproduce this with FreeCAD on Ubuntu 22.04.
There are a lot of possible root causes for this error message, because it's coming from a low-level component that just doesn't have the necessary information to provide more context. #2200 was fixed by #2710; #3477 is the same error message for a different reason; and this one might be the same as #3477, or something different. We can't know without more details.
You're replacing die_with_error() with fprintf()? That's a workaround, not a solution, and might equally well break something else. bubblewrap is intentionally failing with an error message in situations where what it has been asked to do is impossible, and it's up to a larger component (in this case Flatpak) to ask it to do something that is possible instead.
Please attach the Flatpak verbose log so that we can see what is breaking this.
I think this is another report of the same root cause as #3477. Key factors:
you have a symlink in the root directory (in your case it's /media) pointing to a path below /var/run
/var/run is itself a symlink to /run
your app has the --filesystem=host or --filesystem=/media permission
Flatpak tries to preserve the symlink structure of the host system to the best of its ability, which includes creating a symlink /var/run -> /run; but that conflicts with the setup that Flatpak already does in /var/run and /run.
Workaround: remove the /var/run/media symlink, and replace it with a symlink to /run/media, which should have equivalent behaviour while avoiding this bug.
I'm closing this as a duplicate of #3477 since it seems to be a good match for what happened there.
Workaround: remove the /var/run/media symlink, and replace it with a symlink to /run/media, which should have equivalent behaviour while avoiding this bug.
Please try reverting your workaround in bubblewrap, and doing this instead.
Do you mean you still get "Can't make symlink at /var/run: File exists", even with /media -> /run/media? Or some similar message? Either way, please collect a new log.
It would also be useful to know whether the app has any overrides, similar to #3477 (comment).
Flatpak 1.12.5 is an old version. If you're able to run 1.14.x or even 1.15.x (either at OS level or compiled from source), that has considerably better diagnostic messages for exports/filesystem handling - older versions only tell us what they are doing, but from 1.14.0 onwards it also tells us why.
fp.log
Here is a log with the latest version.
F: /var is not a symlink
F: /var/run is a symlink, resolved to /var/../run
F: Trying to export the target instead: /var/../run/media
F: Trying to export read/write: /var/../run/media
F: /run is not a symlink
F: /run/media is not a symlink
F: Will export read/write: /run/media
F: Will create symbolic link: /var/run <===
F: Will create symbolic link: /media
This is the wrong behavior since it has already detected that /var/run is a symbolic link. If the link exists, it should not create a new one. It also does not matter if /var/run is a link to /run or to ../run. I suspect that it will also fail when it tries to create the /media symbolic link since it also already exists.
It might also make sense to use the realpath function to resolve these to absolute paths.
Thanks, that log clarifies what is happening. However, it still looks like #3477. You said "/media now points to /run/media instead of /var/run/media" which would be the workaround for #3477; but in your latest log, Flatpak still says F: /media is a symlink, resolved to /var/run/media which implies that you either didn't use that workaround, or used that workaround but then reverted it.
If you replace /media -> /var/run/media with /media -> /run/media, does that make launching the app succeed?
If yes, then this issue is the same as #3477 (which brings us one step closer to solving it, because we already know how to reproduce #3477 and why it's a problem).
If no, then please share a log using a recent Flatpak, but with the workaround in place, so that you are not experiencing #3477, and we can investigate the new problem that is (so far) unique to you.
This is the wrong behavior since it has already detected that /var/run is a symbolic link. If the link exists, it should not create a new one.
If we were creating symlinks on the host system, you'd be right, but that's not what Flatpak is doing: it's creating symlinks inside the Flatpak sandbox, which mirror the structure of the relevant directories on the host system. The Flatpak sandbox starts as an empty tmpfs, then we mount the Flatpak runtime onto /usr, mount the app onto /app, populate /etc, /var and /run in more complicated ways (see the source code for details), and create symlinks and bind-mounts for all the --filesystem paths that are shared between the host system and the app.
The problem in #3477 is that /var/run, specifically, is something that we can't create in a generic way like this, because a different part of the Flatpak code already creates /var/run as part of our setup for /var and /run.
It might also make sense to use the realpath function to resolve these to absolute paths
Flatpak does use realpath in many places, but we are not just trying to replicate the real directories inside the sandbox, we also need to replicate the structure of symlink -> symlink -> symlink -> real directory. We can't do that with realpath: we have to use readlink and reconstruct the structure from there.
If we didn't do that, then we would get weird bugs when a configuration file or other state refers to the same directory by multiple paths that are equivalent on the host system but not equivalent inside the container. For instance, if you have an external disk mounted on /run/media/usbdisk, and a configuration file that variously points to /run/media/usbdisk/file.1, /media/usbdisk/file.2 and /var/run/media/usbdisk/file.3, then that configuration won't work unless we make usbdisk appear at all of those paths - and we prefer to use symlinks rather than bind mounts for this, because the closer we are to the structure seen on the host system, the better it will work.
I suspect that it will also fail when it tries to create the /media symbolic link since it also already exists.
Similarly, this is not trying to overwrite /media on your host system: that would fail, not just because it already exists but also because you're not root. It's trying to create /media inside the Flatpak sandbox, which is in a tmpfs where /media does not exist, until/unless we ask for it.
On Thu, Jan 12, 2023, 6:03 AM Simon McVittie ***@***.***> wrote:
As I tried to indicate on #2200
<#2200>, we are not going to be
able to magically solve this without more information, so please provide
the output of flatpak run -v -v org.freecadweb.FreeCAD.
There are a lot of possible root causes for this error message, because
it's coming from a low-level component that just doesn't have the necessary
information to provide more context. #2200
<#2200> was fixed by #2710
<#2710>; #3477
<#3477> is the same error
message for a different reason; and this one might be the same as #3477
<#3477>, or something different.
We can't know without more details.
This was closed in issue #2000
<#2000>
I think you mean #2200 <#2200>.
#2000 <#2000> looks like
something unrelated.
—
Reply to this email directly, view it on GitHub
<#5255 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADJUAEYX3G43XI7OBV3PXDDWSAFK3ANCNFSM6AAAAAATZHZS3I>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
changed the title [-][Bug]: bwrap: Can't make symlink at /var/run: File exists[/-][+][Bug]: bwrap: Can't make symlink at /var/run: File exists, involving /var/run/media[/+]on Jan 18, 2023
It looks like changing the /media symlink fixes the issue. It is now working.
That implies that at least this part of your issue report was a duplicate of #3477, which is already tracked.
I am still seeing this error with Steam flatpak games.
Even with /media -> /run/media? If yes, please describe how to reproduce the issue, and show me a log, preferably from 1.14.x or 1.15.x. If you have /media -> /run/media and you still get this, then this part will not be a duplicate of #3477.
is the issue reproduced by launching Steam itself, or by launching a "non-Steam game" that is itself a Flatpak app, or by launching a Steam game that uses Proton or Steam Linux Runtime, or what?
Not OP here, but I can provide a sample of Steam failing to run when symlinks are involved.
This is with Flapak 1.14.4. The user was created specifically to demonstrate this fault. Beginning with an essentially empty home directory and no user-specific environment variables, I created ~/.var/real-app as a directory with ~/.var/app as a symlink to that. Attempting to run Steam (via the unofficial Flatpak app) fails with:
bwrap: Can't make symlink at /home/steam/.var/app: File exists
It seems like bwrap dies when creating the symlink fails. A possible solution might be for bwrap to not treat symlink() returning non-zero as an error if errno is EEXIST and the existing path is already a symlink to the desired target. I will admit that I don't know how tricky this becomes with the containers involved, or I'd submit a patch myself.
A possible solution might be for bwrap to not treat symlink() returning non-zero as an error if errno is EEXIST and the existing path is already a symlink to the desired target.
That's containers/bubblewrap#549, pull requests welcome (I'm unlikely to have time to implement it any time soon). It's in quite low-level code, but shouldn't be particularly difficult to implement.
I think this is another report of the same root cause as #3477. Key factors:
you have a symlink in the root directory (in your case it's /media) pointing to a path below /var/run
/var/run is itself a symlink to /run
your app has the --filesystem=host or --filesystem=/media permission
Flatpak tries to preserve the symlink structure of the host system to the best of its ability, which includes creating a symlink /var/run -> /run; but that conflicts with the setup that Flatpak already does in /var/run and /run.
Workaround: remove the /var/run/media symlink, and replace it with a symlink to /run/media, which should have equivalent behaviour while avoiding this bug.
I'm closing this as a duplicate of #3477 since it seems to be a good match for what happened there.
This helped me for Steam installed via flatpak on Fedora Silverblue. My use case was that I also allowed additional filesystem paths (that are mounted on separate drive under /run/media/) for games and mesa cache
Activity
smcv commentedon Jan 12, 2023
As I tried to indicate on [edit: #2710], we are not going to be able to magically solve this without more information, so please provide the output of
flatpak run -v -v org.freecadweb.FreeCAD(or any other app that shows the same symptom, the simpler the better). For what it's worth, I can't reproduce this with FreeCAD on Ubuntu 22.04.There are a lot of possible root causes for this error message, because it's coming from a low-level component that just doesn't have the necessary information to provide more context. #2200 was fixed by #2710; #3477 is the same error message for a different reason; and this one might be the same as #3477, or something different. We can't know without more details.
I think you mean #2200. #2000 looks like something unrelated.
aaronw2 commentedon Jan 12, 2023
If I change line 1466 in bubblewrap.c to fprintf(stderr, ...) it works.
smcv commentedon Jan 12, 2023
You're replacing
die_with_error()withfprintf()? That's a workaround, not a solution, and might equally well break something else. bubblewrap is intentionally failing with an error message in situations where what it has been asked to do is impossible, and it's up to a larger component (in this case Flatpak) to ask it to do something that is possible instead.Please attach the Flatpak verbose log so that we can see what is breaking this.
aaronw2 commentedon Jan 12, 2023
fp.log
I agree it's a workaround, but I've been hitting this bug for quite some time and need a quick way to continue.
smcv commentedon Jan 12, 2023
aaronw2 commentedon Jan 12, 2023
This also fixed SteamVR for me as well.
smcv commentedon Jan 12, 2023
I think this is another report of the same root cause as #3477. Key factors:
/media) pointing to a path below/var/run/var/runis itself a symlink to/run--filesystem=hostor--filesystem=/mediapermissionFlatpak tries to preserve the symlink structure of the host system to the best of its ability, which includes creating a symlink
/var/run -> /run; but that conflicts with the setup that Flatpak already does in/var/runand/run.Workaround: remove the
/var/run/mediasymlink, and replace it with a symlink to/run/media, which should have equivalent behaviour while avoiding this bug.I'm closing this as a duplicate of #3477 since it seems to be a good match for what happened there.
smcv commentedon Jan 12, 2023
Please try reverting your workaround in bubblewrap, and doing this instead.
aaronw2 commentedon Jan 12, 2023
I hit the same problem. /media now points to /run/media instead of /var/run/media.
smcv commentedon Jan 12, 2023
Do you mean you still get "Can't make symlink at /var/run: File exists", even with
/media -> /run/media? Or some similar message? Either way, please collect a new log.It would also be useful to know whether the app has any overrides, similar to #3477 (comment).
Flatpak 1.12.5 is an old version. If you're able to run 1.14.x or even 1.15.x (either at OS level or compiled from source), that has considerably better diagnostic messages for exports/filesystem handling - older versions only tell us what they are doing, but from 1.14.0 onwards it also tells us why.
aaronw2 commentedon Jan 12, 2023
fp.log
Here is a log with the latest version.
F: /var is not a symlink
F: /var/run is a symlink, resolved to /var/../run
F: Trying to export the target instead: /var/../run/media
F: Trying to export read/write: /var/../run/media
F: /run is not a symlink
F: /run/media is not a symlink
F: Will export read/write: /run/media
F: Will create symbolic link: /var/run <===
F: Will create symbolic link: /media
This is the wrong behavior since it has already detected that /var/run is a symbolic link. If the link exists, it should not create a new one. It also does not matter if /var/run is a link to /run or to ../run. I suspect that it will also fail when it tries to create the /media symbolic link since it also already exists.
It might also make sense to use the realpath function to resolve these to absolute paths.
smcv commentedon Jan 13, 2023
Thanks, that log clarifies what is happening. However, it still looks like #3477. You said "/media now points to /run/media instead of /var/run/media" which would be the workaround for #3477; but in your latest log, Flatpak still says
F: /media is a symlink, resolved to /var/run/mediawhich implies that you either didn't use that workaround, or used that workaround but then reverted it.If you replace
/media -> /var/run/mediawith/media -> /run/media, does that make launching the app succeed?If yes, then this issue is the same as #3477 (which brings us one step closer to solving it, because we already know how to reproduce #3477 and why it's a problem).
If no, then please share a log using a recent Flatpak, but with the workaround in place, so that you are not experiencing #3477, and we can investigate the new problem that is (so far) unique to you.
If we were creating symlinks on the host system, you'd be right, but that's not what Flatpak is doing: it's creating symlinks inside the Flatpak sandbox, which mirror the structure of the relevant directories on the host system. The Flatpak sandbox starts as an empty tmpfs, then we mount the Flatpak runtime onto
/usr, mount the app onto/app, populate/etc,/varand/runin more complicated ways (see the source code for details), and create symlinks and bind-mounts for all the--filesystempaths that are shared between the host system and the app.The problem in #3477 is that
/var/run, specifically, is something that we can't create in a generic way like this, because a different part of the Flatpak code already creates/var/runas part of our setup for/varand/run.Flatpak does use
realpathin many places, but we are not just trying to replicate the real directories inside the sandbox, we also need to replicate the structure of symlink -> symlink -> symlink -> real directory. We can't do that withrealpath: we have to usereadlinkand reconstruct the structure from there.If we didn't do that, then we would get weird bugs when a configuration file or other state refers to the same directory by multiple paths that are equivalent on the host system but not equivalent inside the container. For instance, if you have an external disk mounted on
/run/media/usbdisk, and a configuration file that variously points to/run/media/usbdisk/file.1,/media/usbdisk/file.2and/var/run/media/usbdisk/file.3, then that configuration won't work unless we makeusbdiskappear at all of those paths - and we prefer to use symlinks rather than bind mounts for this, because the closer we are to the structure seen on the host system, the better it will work.Similarly, this is not trying to overwrite
/mediaon your host system: that would fail, not just because it already exists but also because you're not root. It's trying to create/mediainside the Flatpak sandbox, which is in a tmpfs where/mediadoes not exist, until/unless we ask for it.aaronw2 commentedon Jan 13, 2023
[-][Bug]: bwrap: Can't make symlink at /var/run: File exists[/-][+][Bug]: bwrap: Can't make symlink at /var/run: File exists, involving /var/run/media[/+]aaronw2 commentedon Jan 19, 2023
It looks like changing the /media symlink fixes the issue. It is now working.
aaronw2 commentedon Jan 19, 2023
I am still seeing this error with Steam flatpak games.
smcv commentedon Jan 19, 2023
That implies that at least this part of your issue report was a duplicate of #3477, which is already tracked.
Even with
/media -> /run/media? If yes, please describe how to reproduce the issue, and show me a log, preferably from 1.14.x or 1.15.x. If you have/media -> /run/mediaand you still get this, then this part will not be a duplicate of #3477.Some of the details that will be relevant:
jkaivo commentedon Apr 20, 2023
Not OP here, but I can provide a sample of Steam failing to run when symlinks are involved.
This is with Flapak 1.14.4. The user was created specifically to demonstrate this fault. Beginning with an essentially empty home directory and no user-specific environment variables, I created
~/.var/real-appas a directory with~/.var/appas a symlink to that. Attempting to run Steam (via the unofficial Flatpak app) fails with:Full Logs
It seems like
bwrapdies when creating the symlink fails. A possible solution might be forbwrapto not treatsymlink()returning non-zero as an error iferrnoisEEXISTand the existing path is already a symlink to the desired target. I will admit that I don't know how tricky this becomes with the containers involved, or I'd submit a patch myself.smcv commentedon Apr 21, 2023
That's containers/bubblewrap#549, pull requests welcome (I'm unlikely to have time to implement it any time soon). It's in quite low-level code, but shouldn't be particularly difficult to implement.
jkaivo commentedon Apr 21, 2023
Pull request submitted. I was able to run Steam in exact same scenario as before without issues.
AleVul commentedon Dec 7, 2023
This helped me for Steam installed via flatpak on Fedora Silverblue. My use case was that I also allowed additional filesystem paths (that are mounted on separate drive under /run/media/) for games and mesa cache
Update submodule: bubblewrap 0.9.0
Update submodule: bubblewrap 0.9.0
Update submodule: bubblewrap 0.9.0