Does setting environment variables work with override-build?

Sorry @frederickjh, this post wasn’t in the snapcraft category so I never saw it (I’ve fixed that now).

I’m afraid snapcraftctl doesn’t quite work this way, nor was it designed to. When you run snapcraftctl build, snapcraftctl isn’t the utility actually building, it’s still the parent snapcraft CLI, which is running under its own environment. When you call snapcraftctl build, you’re literally saying “please run the build exactly as you would have otherwise”. If you need to customize the build process to this extend, you’ll need to completely override it in the scriptlet, or implement a plugin that exports the proper environment for the build process.

Beyond that, note that the environment variable $SNAP has no meaning in snapcraft-- it only means something when the resulting snap is installed. Which means the environment variable you’re setting there isn’t valid anyway, so I’m not quite clear what you’re trying to do.

1 Like