I'm using electron-builder to generate the AppImage and found this package is used for that.
When running my app with npm start it can find java from the env var JAVA_HOME that is part of my PATH env var.
Though when I execute the AppImage, the PATH that is shown is not the PATH from my env, one thing that doesn't have and it's needed by the app is the JAVA_HOME.
The issue is that java is needed because my app users exec() to execute a CLI that is built on java, os it's executed like $ java -cp app.jar path.to.Main, and from the AppImage I get "java not found".
The other problem is I can't hardcode a path via a .env file, because anyone using the app will have Java installed on different paths, and the standard way to find it is by defining the env var JAVA_HOME and to JAVA_HOME be on the PATH env var.
Though I don't know if there is any option to do that safely and without the need of extracting and repackaging the AppImage (I would like to configure it and then just build the dist).
I can't find any documentation about this specific issue or examples showing how to customize env vars, so I'm blocked in terms of distributing my app. Any pointers are welcome.
I'm using electron-builder to generate the AppImage and found this package is used for that.
When running my app with npm start it can find java from the env var JAVA_HOME that is part of my PATH env var.
Though when I execute the AppImage, the PATH that is shown is not the PATH from my env, one thing that doesn't have and it's needed by the app is the JAVA_HOME.
The issue is that java is needed because my app users exec() to execute a CLI that is built on java, os it's executed like
$ java -cp app.jar path.to.Main
, and from the AppImage I get "java not found".The other problem is I can't hardcode a path via a .env file, because anyone using the app will have Java installed on different paths, and the standard way to find it is by defining the env var JAVA_HOME and to JAVA_HOME be on the PATH env var.
So maybe somewhere like here https://github.com/develar/app-builder/blob/0bc38fb5e76c38ab24e36acf7a17887370e31fb4/pkg/package-format/appimage/templates/AppRun.sh#L25 could be used to add an extra export JAVA_HOME="${JAVA_HOME}"
Though I don't know if there is any option to do that safely and without the need of extracting and repackaging the AppImage (I would like to configure it and then just build the dist).
While researching I've found this that shows setting the JAVA_HOME in the AppRun (I would prefer something that could be configured): https://gist.github.com/neilcsmith-net/69bcb23bcc6698815438dc4e3df6caa3#file-nb2appimage-sh-L75-L88
Also asked on the electron repo with my findings and data there: https://github.com/electron/electron/issues/41380
I can't find any documentation about this specific issue or examples showing how to customize env vars, so I'm blocked in terms of distributing my app. Any pointers are welcome.