I understand that you can specify environment vars in snapcraft.yaml.
My reading seems to imply that these environment variables will be written to the loader.
I can see them in snap.yaml but the loader isn’t affected.
they’re not written into the command-pi-gation.wrapper or equivalent for your app. Instead they are managed internally by snapd before it calls that wrapper. This confused me at first, too. You can verify whether the environment variable is set correctly by running:
snap run --shell pi-gation
echo $PI4J_PLATFORM
exit
#!/bin/sh
ARCH=`uname -m`
if [ "$SNAP_ARCH" != "arm64" ] && [ "$SNAP_ARCH" != "armhf" ]; then
# Run the simulator as we are not on RPi hardware
export PI4J_PLATFORM="Simulated"
export SimulatedPlatform="RaspberryPi GPIO Provider"
fi
export pi_gation_db_username="`snapctl get pi-gation db-username`"
export pi_gation_db_password="`snapctl get pi-gation db-password`"
export pi_gation_https_port="`snapctl get pi-gation https-port`"
$SNAP/tomcat-launch