← Back to issue list

no way to differentiate between build-time and run-time env vars in plugins

View original Launchpad issue

Metadata

Project
snapcraft (launchpad)
Number
#1600035
Type
issue
State
open
Author
~thomir-deactivatedaccount
Labels
—
Created
Updated
Closed
—

Current evaluation

Legacy plugin env() conflated build and runtime variables; separate plugin build-environment support and part-level build-environment handling were later implemented.

Suggested action: close resolved

Reason: The promised separation is present: current parts support build_environment, plugins expose get_build_environment(), and commit d17b67d20 / PR #2322 added the part property, while 8ca7dd7f2 / PR #2472 prevented it leaking. This also addresses the maintainer's 2016 direction to use the godeps-style build-only mechanism while reserving env() for runtime bits.

Evaluated by: mr-cal-bot

Impact: 48 Quick Win: 25 Complexity: 46 Confidence: 97 Actionability: 96

Issue body

As far as I can tell, BasePlugin has one method for manipulating environment variables: the env() method. I have a custom plugin where I need to be able to set certain environment variables at build-time, so I'm setting them in this method like so: ``` def env(self, root): env = super().env(root) env.extend([ 'CPPFLAGS="-std=c++11 -I{} $CPPFLAGS"'.format(os.path.join( root, 'usr', 'include')), 'CFLAGS="-std=c11 -I{} $CFLAGS"'.format(os.path.join( root, 'usr', 'include')), ]) return env ``` This works fine for building the snap, but I notice that these environment variables are then present in the command wrapper as well, so they're also being set for runtime. Most of the time this won't be a massive issue - setting CPPFLAGS has no effect at run-time, but it's a little surprising, and I can imagine situations where plugin authors will want more control over what's set at build time, and what's set at run-time.

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha
Impact: 48
Quick Win: 25
Complexity: 46
Confidence: 97
Actionability: 96
close resolved Legacy plugin env() conflated build and runtime variables; separate plugin build-environment support and part-level build-environment handling were later implemented.
stealth/space-bunny-alpha
Impact: 42
Quick Win: 25
Complexity: 38
Confidence: 98
Actionability: 97
close resolved Legacy plugin env() merged build-only and runtime variables. Separate build-environment support was later implemented for parts and plugins, resolving the conflation.
qwen/qwen3.6-35b-a3b
Impact: 0
Quick Win: 0
Complexity: 0
Confidence: 95
Actionability: 100
close resolved Issue requesting differentiation between build-time and run-time env vars in plugins. Resolved: old `env()` method removed, current `get_build_environment()` is build-step only.
qwen3.6-35b-a3b-mtp-q6
Impact: 50
Quick Win: 30
Staleness: 95
Complexity: 40
Confidence: 65
Support Request: 30
close stale Feature request to differentiate build-time vs run-time environment variables in plugin BasePlugin.env() method. Issue is 10 years old with no maintainer engagement or comments.
qwen/qwen3.6-35b-a3b
Staleness: 95
Complexity: 15
Confidence: 85
Support Request: 5
needs triage Feature request to separate build-time and run-time environment variables in plugins. Currently, the env() method applies variables to both phases. Untriaged, zero maintainer comments, and over 10 years old.
qwen/qwen3.6-35b-a3b
Staleness: 95
Complexity: 65
Confidence: 85
Support Request: 10
close stale Feature request to separate build-time and runtime environment variables in plugins. Currently, a single env() method applies to both phases. Unlabeled, no maintainer response, inactive for over seven years.
qwen3.6-35b-a3b-mtp-q6
Staleness: 95
Complexity: 65
Confidence: 85
Support Request: 10
needs triage Plugin env() method applies environment variables to both build and runtime contexts. No maintainer response after over a decade. Lacks labels and formal assessment.

Update history

Date Change
created

Related work

  • Likely Fixed By: snapcraft#2322 (confidence 99%)

    Commit d17b67d20 adds the part-level build-environment property promised in the issue discussion.

  • Related To: snapcraft#2472 (confidence 97%)

    Commit 8ca7dd7f2 fixes leakage of a part's build-environment, reinforcing the build/runtime separation.

Related issues

No related issues found above the similarity threshold.