Can I add a top-level directory for data dependencies?


OK, I’ve learned that any data dependencies must be placed under usr/.
Is that a hard requirement, or is there a way to add a new directory available to my application?


Hi, How does an app reference files that are packaged in the app image? I’m getting failure trying to open a file whose path is relative to the AppDir root:
Could not read file external/testdata/data.txt: No such file or directory
Where external/testdata/data.txt does exist in the app image.


Welcome Matthew!

You can place data wherever you like inside the AppImage, but we recommend to use the customary usr/ tree inside the AppImage. So binaries would go in usr/bin and data in usr/share/appname. Remember that an AppImage is just a filesystem image that mounts itself when executed and runs a file called AppRun inside it. What is going on from there is up to you.


Thanks for your reply.

When I put a data directory external/testdata into my AppDir, it did not exist inside the AppImage. Files there we not found. Only when I moved them to usr/external/testdata were they visible in the app image.
All this was determined by inspecting the filesystem from within my app.

Is there some configuration which tells what directories to put into the app image?


Correction: What I observe is that the app starts up with a PWD of usr/. The data directory is visible after all, but as ../external.
Is that expected? Is there a way to specify the starting directory?


Ah. I now see that AppRun.c sets it up this way, doing a chdir(usr/). That explains my confusion. Sorry for all the chatter.


AppRun.c sets it up this way, doing a chdir(usr/).

Correct. But you don’t have to use this AppRun, you could also use your own script or even a link to your binary in its place. A safer method would be to find out the absolute path to your main executable, and calculate an absolute path to your data based on that, e.g., using the information from /proc/self/exe.