← Back to issue list

`SNAPCRAFT_BUILD_ENVIRONMENT` takes priority over `--use-lxd`

View original Github issue

Metadata

Project
snapcraft
Number
#4832
Type
issue
State
open
Author
mr-cal
Labels
Status: Triaged Type: Bug
Created
Updated
Closed

Current evaluation

SNAPCRAFT_BUILD_ENVIRONMENT was overriding the --use-lxd CLI flag; CRAFT_MANAGED_MODE precedence is intended per maintainer. Fixed by merged PR #4329 (commit 7f8d4cff9) which prioritizes the flag; issue remains open and can be closed.

Suggested action: close stale

Reason: The bug portion is fixed: merged PR #4329 (commit 7f8d4cff9, 'cli: prioritize --use-lxd over SNAPCRAFT_BUILD_ENVIRONMENT') is in current HEAD, and get_provider() now checks the CLI-provided provider before the env var. The maintainer also confirmed in a comment that CRAFT_MANAGED_MODE behavior is correct, so the original problem is no longer reproducible and the issue has been inactive for ~7 months.

Impact: 45 Quick Win: 36.0 Staleness: 55 Complexity: 20 Confidence: 85 Support Request: 5

Issue body

### Bug Description `CRAFT_MANAGED_MODE` and `SNAPCRAFT_BUILD_ENVIRONMENT` take priority over `--use-lxd` See https://github.com/canonical/craft-application/issues/354 ### To Reproduce ```shell SNAPCRAFT_BUILD_ENVIRONMENT=host snapcraft pack --use-lxd CRAFT_MANAGED_MODE=1 snapcraft pack --use-lxd ``` ### Environment n/a ### snapcraft.yaml ```shell n/a ``` ### Relevant log output ```shell n/a ``` ### Additional context _No response_

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 45
Quick Win: 36.0
Staleness: 55
Complexity: 20
Confidence: 85
Support Request: 5
close stale SNAPCRAFT_BUILD_ENVIRONMENT was overriding the --use-lxd CLI flag; CRAFT_MANAGED_MODE precedence is intended per maintainer. Fixed by merged PR #4329 (commit 7f8d4cff9) which prioritizes the flag; issue remains open and can be closed.
qwen/qwen3.6-35b-a3b
Staleness: 75
Complexity: 30
Confidence: 85
Support Request: 5
keep open SNAPCRAFT_BUILD_ENVIRONMENT incorrectly overrides the --use-lxd CLI flag during snapcraft pack. Issue is triaged and acknowledged by a maintainer, awaiting a fix.
qwen3.6-35b-a3b-mtp-q6
Staleness: 45
Complexity: 30
Confidence: 85
Support Request: 5
keep open Environment variables CRAFT_MANAGED_MODE and SNAPCRAFT_BUILD_ENVIRONMENT incorrectly override the --use-lxd CLI flag. Triaged bug, last discussed in May 2024 with maintainer clarification.
qwen3.6-35b-a3b-mtp-q6
Staleness: 65
Complexity: 30
Confidence: 85
Support Request: 5
keep open SNAPCRAFT_BUILD_ENVIRONMENT incorrectly overrides the --use-lxd CLI flag, unlike CRAFT_MANAGED_MODE which is intentional. The bug is triaged and awaiting implementation.

Update history

No update history recorded yet.

Related work

  • Likely Fixed By: snapcraft#4329 (confidence 90%)

    Merged PR 'cli: prioritize --use-lxd over SNAPCRAFT_BUILD_ENVIRONMENT'; commit 7f8d4cff9 is in current HEAD and lifecycle.py now passes use_lxd as the provider argument, which get_provider() ranks above the env var.

  • Related To: craft-application#354 (confidence 80%)

    Upstream craft-application issue explicitly referenced in the body regarding --use-lxd vs CRAFT_BUILD_ENVIRONMENT precedence.

  • Duplicate Of: snapcraft#4307 (confidence 75%)

    User report of the same SNAPCRAFT_BUILD_ENVIRONMENT-overrides---use-lxd bug, closed as resolved by the same fix; this issue is the maintainer's tracking issue for it.

Related issues

Issue Project State Summary Similarity
#4307 SNAPCRAFT_BUILD_ENVIRONMENT apparently takes precedence over "--use-lxd" snapcraft closed Fixed via PR #4330. The SNAPCRAFT_BUILD_ENVIRONMENT environment variable no longer overrides the --use-lxd CLI flag. Command line arguments now correctly take precedence over environment variables for build provider selection.
88%
#4329 cli: prioritize `--use-lxd` over `SNAPCRAFT_BUILD_ENVIRONMENT` snapcraft merged Merged. Prioritizes the --use-lxd CLI argument over the SNAPCRAFT_BUILD_ENVIRONMENT environment variable, resolving issue #4307. Approved by reviewer, passed CI checks, and achieved 100% diff coverage.
84%
#354 Prefer `--use-lxd` over `CRAFT_BUILD_ENVIRONMENT` craft-application open CLI flag --use-lxd is ignored when CRAFT_BUILD_ENVIRONMENT=host is set; _use_provider() in lifecycle.py doesn't check the flag before the env var. Untriaged, no labels or maintainer response; bug still present in current code.
78%
#1841892 snapcraft options are position-dependent snapcraft (launchpad) open Reports snapcraft CLI flags are position-dependent: `snapcraft --use-lxd build` silently ignores the flag while `snapcraft build --use-lxd` works. Unanswered for ~7 years; `--use-lxd` was later removed from snapcraft, making the example obsolete.
71%