Controlling the environment at invocation

I’m packaging a build script which invokes other programs execlp style. These are installed as stage-packages. It would be useful to set environmental variables after the invocation of the program which would point to snap specific binaries. (E.g. programs are searching for toolchains under /usr/bin/c++. This can be overridden by an environment variable.) Is there anyway to do this with snapcraft? Or is my best bet to write and expose a shell script which sets up the environment prior to invoking the program?

you can add an environment: block to your apps: entry to export custom env variables:

like this:

1 Like