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
When I supply file name of video as relative path in command line argument to AppImage file (VLC), it is treated as relative to appimage's internal file structure.
To make it work, one must specify absolute path of file
Also when file name in command line argument contains spaces, AppImage is not able to open it.
Yes @crayxt this is because in order to make some binaries relocateable, we patch /usr to ././ at AppDir creation time which means "the current directory". Hence at runtime we cd to the AppDir's usr/ before running the payload.
Ok, first, I try to avoid using absolute paths instead of cd'ing in my AppRun as much as possible (see for instance this generic AppRun for simple games)
However, because some apps need the binary to be run from a specific local directory and I need to cd, I have a script that turns all relative arguments in absolute arguments before cd'ing
. "$APPDIR/util.sh"
# Uncomment this if the app needs relative paths specified on the command line
eval arguments="$(patch_relative_paths "$@")"
set -- "${arguments[@]}"
The script is located here and you can see it in action here.
It only works on files that exist, that's the only way I have of knowing when to transform an argument. It would work in vim existing_file_to_edit.txt but not in vim new_file_to_create.txt
It's a bit intrussive, as we're rewriting all the relative paths, and some app may not want that
This patch is a neat workaround, but when a binary cannot be relocated it should really be reported as a bug to the upstream developers. If upstream relies on absolute paths for locating resources normally found in /usr/share then a 2-step solution like this one can be used in the upstream code.
Activity
RazZziel commentedon Apr 14, 2016
I've got a fix for that in PortableLinuxGames, I'll look for it hopefully this evening
probonopd commentedon Apr 14, 2016
Yes @crayxt this is because in order to make some binaries relocateable, we patch
/usrto././at AppDir creation time which means "the current directory". Hence at runtime we cd to the AppDir'susr/before running the payload.Cool @RazZziel looking forward to it.
RazZziel commentedon Apr 15, 2016
Ok, first, I try to avoid using absolute paths instead of cd'ing in my AppRun as much as possible (see for instance this generic AppRun for simple games)
However, because some apps need the binary to be run from a specific local directory and I need to cd, I have a script that turns all relative arguments in absolute arguments before cd'ing
The script is located here and you can see it in action here.
probonopd commentedon Apr 15, 2016
Can you do this in C?
RazZziel commentedon Apr 21, 2016
Thechnically, it shouldn't be a problem, it would be something like this:
Which is executed before the line:
Output:
The problem is:
vim existing_file_to_edit.txtbut not invim new_file_to_create.txtprobonopd commentedon Apr 21, 2016
Thanks @RazZziel. I'd say, let's go for it' but I'd like to hear the opinion of others too. Maybe add a
--appimage-no-path-rewriteoption?shoogle commentedon Jun 19, 2016
This patch is a neat workaround, but when a binary cannot be relocated it should really be reported as a bug to the upstream developers. If upstream relies on absolute paths for locating resources normally found in
/usr/sharethen a 2-step solution like this one can be used in the upstream code.probonopd commentedon Nov 5, 2016
The new
union: trueoption for.ymlfiles might mitigate the need for this, because when set, then no chdir is done.