Snappy needs to influence environment variables in applications
Metadata
Current evaluation
Snapcraft gained top-level and per-app environment keys in snap.yaml, merged in snapcraft#1103 (c66f55656). The review-tool SRU 0.44~16.04.1 was verified and released.
Resolution: closed resolved
Reason: Environment-key support was merged in snapcraft#1103 at commit c66f55656, replacing application wrapper scripts. click-reviewers-tools 0.44~16.04.1 passed verification and was released to xenial-updates.
Evaluated by: mr-cal-bot
No scores available.
Issue body
= SRU for snapcraft =
[Impact]
* Adding an environment keyword to snapcraft.yaml, which will make it to snap.yaml which the launcher will use to setup the environment.
* This reduces the amount of wrapper files.
[Test Case]
1. Run `snapcraft` on the ros demo.
2. Install the snap.
3. snap should run. (if it doesn't it mostly likely means the environent was setup incorrectly).
4. snap.yaml's `assumes` gets a `snap-run` tag.
[Regression Potential]
* Very low. Environment that was previously setup by wrapper scripts could be missing when the launcher launches using the environment keyword.
* The use of `assumes` will make sure this doesn't break people on older versions of snapd or snap-run
= SRU for click-reviewers-tools =
[Impact]
This is already fixed in the store so the SRU is for users to not see this failure their local system
[Test Case]
Run snap-review on the attached snap:
$ snap-review ./snap-example-env_0_all.snap
./snap-example-env_0_all.snap: pass
[ Regression Potential]
Regression potential is extremely low since this is already on production in the Ubuntu Store for many weeks.
= Original description =
We see a common pattern across many snaps, all apps are really using wrappers to set environment variables. I'd like to propose that this is exposed as first class feature in snapcraft (same like plugs and slots), snappy (where interfaces can affect variables and snappy can have sensible defaults) and ubuntu-core-launcher (to actually apply those variables to each started process).
As a bit of context, this is a wrapper for a non trivial but still common app: the calculator:
https://bazaar.launchpad.net/~ubuntu-desktop/+junk/gnome-calculator-snap/view/head:/calc#L3
The wrapper is 44 lines long, all of which set up environment variables.
Support environment variable that would be available to snaps. The form should look like
snapcraft.yaml
name: ...
version: ...
...
environment: # these apply to all snaps
ENV1: value1
ENV2: value2
apps:
app1:
...
environment:
ENV1: value1 # takes precedence over global ones
These environment values would be transported to snap.yaml
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Snapcraft gained top-level and per-app environment keys in snap.yaml, merged in snapcraft#1103 (c66f55656). The review-tool SRU 0.44~16.04.1 was verified and released. | |
| stealth/space-bunny-alpha | — | closed resolved | Snapcraft added global and per-app environment support in PR #1103 (commit c66f55656); click-reviewers-tools 0.44~16.04.1 was verified and released to xenial-updates. | |
| stealth/space-bunny-alpha | — | closed resolved | Environment-variable support was merged in snapcraft PR #1103 (c66f55656), propagating the environment keyword from snapcraft.yaml to snap.yaml and reducing wrapper scripts. | |
| qwen/qwen3.6-35b-a3b | — | — | Implemented via SRU for snapcraft and click-reviewers-tools. Added an environment keyword to snapcraft.yaml that populates snap.yaml, reducing wrapper scripts. Compatibility ensured with an assumes tag for older snapd versions. | |
| qwen/qwen3.6-35b-a3b | — | — | Fixed via SRUs for snapcraft and click-reviewers-tools. Added an environment keyword to snapcraft.yaml that populates snap.yaml, enabling the launcher to apply variables directly and reducing wrapper scripts. Verified and closed. | |
| qwen/qwen3.6-35b-a3b | — | — | Implemented and released via SRUs for snapcraft and click-reviewers-tools. The environment keyword was added to snapcraft.yaml to pass variables to snap.yaml and the launcher, reducing wrapper scripts. Closed as fixed. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Implemented and released via SRU for snapcraft and click-reviewers-tools. Added environment keyword to snapcraft.yaml to pass variables to snap.yaml and the launcher, reducing wrapper script usage. Verification completed. |
Update history
| Date | Change |
|---|---|
| created |
Related work
-
Likely Fixed By:
snapcraft#1103
(confidence 99%)
Merged as commit c66f55656 with the title "meta: support for the environment keyword."
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #4607 fix(application): support snap/craft environment variables | snapcraft | merged | Merged PR #4607 as b41ebe6e4, adding SNAP/CRAFT environment-variable support to the application and tests. | |
| #3645 meta: parse environment variables (CRAFT-835) | snapcraft | merged | Merged #3645 into snapcraft/7.0 via 7e7089fb1, adding parsing of root- and app-level environment dictionaries from snapcraft.yaml. |