← Back to issue list

SNAPCRAFT_BUILD_ENVIRONMENT apparently takes precedence over "--use-lxd"

View original Github issue

Metadata

Project
snapcraft
Number
#4307
Type
issue
State
closed
Author
ghost
Labels
—
Created
Updated
Closed

Current evaluation

Fixed by merged PR #4329 (commit 7f8d4cff9): --use-lxd now overrides SNAPCRAFT_BUILD_ENVIRONMENT, matching documented precedence.

Resolution: closed resolved

Reason: PR #4329 changed provider selection to prioritize --use-lxd over SNAPCRAFT_BUILD_ENVIRONMENT and was merged as commit 7f8d4cff9.

Evaluated by: mr-cal-bot

No scores available.

Issue body

### Bug Description Despite what is printed here, https://snapcraft.io/docs/build-providers, if I set the env var SNAPCRAFT_BUILD_ENVIRONMENT=host, that appears to take priority over using "--use-lxd" on the command line. ### To Reproduce Set env var SNAPCRAFT_BUILD_ENVIRONMENT=host, then try overriding that with "--use-lxd". ### Environment Ubuntu 22.04 ### snapcraft.yaml ```shell Not relevant. ``` ### Relevant log output ```shell Build is done on host in destructive mode. ``` ### Additional context _No response_

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Fixed by merged PR #4329 (commit 7f8d4cff9): --use-lxd now overrides SNAPCRAFT_BUILD_ENVIRONMENT, matching documented precedence.
stealth/space-bunny-alpha — closed resolved Fixed in canonical/snapcraft#4329, commit 7f8d4cff9: --use-lxd now takes precedence over SNAPCRAFT_BUILD_ENVIRONMENT as documented.
qwen/qwen3.6-35b-a3b — — 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.
qwen/qwen3.6-35b-a3b — — The SNAPCRAFT_BUILD_ENVIRONMENT environment variable incorrectly overriding the --use-lxd CLI flag was confirmed as a bug and resolved by merging pull request #4330.
qwen/qwen3.6-35b-a3b — — SNAPCRAFT_BUILD_ENVIRONMENT incorrectly overriding --use-lxd was confirmed as a bug and resolved by merging pull request 4330, restoring correct CLI flag precedence.
qwen3.6-35b-a3b-mtp-q6 — — The SNAPCRAFT_BUILD_ENVIRONMENT variable incorrectly overriding --use-lxd was confirmed as a bug and fixed by merging pull request 4330, which corrected the precedence logic.

Update history

No update history recorded yet.

Related work

Related issues

Issue Project State Summary Similarity
#4329 cli: prioritize `--use-lxd` over `SNAPCRAFT_BUILD_ENVIRONMENT` snapcraft merged Merged PR #4329 (commit 7f8d4cff9) fixes #4307: get_provider() now checks the CLI --use-lxd argument before SNAPCRAFT_BUILD_ENVIRONMENT, matching documented priority.
85%
#4832 `SNAPCRAFT_BUILD_ENVIRONMENT` takes priority over `--use-lxd` snapcraft open Triaged bug: PR #4329 fixed core22 precedence for SNAPCRAFT_BUILD_ENVIRONMENT, but core24 remains unverified and its spread test is restricted to Ubuntu 22.04; CRAFT_MANAGED_MODE precedence is intentional.
84%
#2179 cli: SNAPCRAFT_BUILD_ENVIRONMENT isn't deprecated snapcraft merged Merged PR #2179 (commit 1ff7550be) by kyrofa fixed the conflicting-env-vars error in the CLI, which wrongly named SNAPCRAFT_BUILD_ENVIRONMENT as deprecated; it now correctly names SNAPCRAFT_CONTAINER_BUILDS.
78%
#354 Prefer `--use-lxd` over `CRAFT_BUILD_ENVIRONMENT` craft-application closed Fixed in PR #1229 by updating _use_provider to check --use-lxd before CRAFT_BUILD_ENVIRONMENT, ensuring CLI flags take priority.
77%
#1229 fix(lifecycle): prefer --use-lxd over CRAFT_BUILD_ENVIRONMENT craft-application merged Merged PR #1229 fixes #354 by making --use-lxd override CRAFT_BUILD_ENVIRONMENT=host to force managed mode in _use_provider, with updated tests and documentation.
73%
#1822265 SNAPCRAFT_BUILD_ENVIRONMENT_* change doesn't apply to existing VMs snapcraft (launchpad) closed Closed by maintainer sergiusens (2019-04-17) as intended behaviour: SNAPCRAFT_BUILD_ENVIRONMENT_* are development/debugging-only variables, so no change was made to apply them to an existing Multipass VM.
71%
#1876260 missing SNAPCRAFT_PART_* variables in override-prime snapcraft (launchpad) closed Missing SNAPCRAFT_PART_* env vars in override-prime fixed by merged PR snapcore/snapcraft#3122 (commit f1f127136), exposing plugin build env to all lifecycle steps while keeping build-environment scoped to build.
70%