← Back to issue list

Prefer `--use-lxd` over `CRAFT_BUILD_ENVIRONMENT`

View original Github issue

Metadata

Project
craft-application
Number
#354
Type
issue
State
open
Author
mr-cal
Labels
Created
Updated
Closed

Current evaluation

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.

Suggested action: needs triage

Reason: No labels, no maintainer comments (only a Jira sync bot), and no assignee — the issue has not been assessed. The bug is confirmed still present: _use_provider() (lifecycle.py:116) returns False when build_environment == 'host' without first checking parsed_args.use_lxd, so CRAFT_BUILD_ENVIRONMENT=host testcraft pack --use-lxd runs locally instead of in LXD.

Impact: 45 Quick Win: 31.5 Staleness: 80 Complexity: 30 Confidence: 75 Support Request: 10

Issue body

### What needs to get done [This function](https://github.com/canonical/craft-application/blob/a39b3cd6a3ee43eaf505988c57cc4d7618029c19/craft_application/commands/lifecycle.py#L93) needs to check if `--use-lxd` was provided. ### Why it needs to get done The following commands will run locally, rather than in a container: ```shell CRAFT_BUILD_ENVIRONMENT=host testcraft pack --use-lxd # for core24 snaps SNAPCRAFT_BUILD_ENVIRONMENT=host snapcraft pack --use-lxd ``` This is wrong because command line arguments should take priority over environment variables

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 45
Quick Win: 31.5
Staleness: 80
Complexity: 30
Confidence: 75
Support Request: 10
needs triage 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.
qwen/qwen3.6-35b-a3b
Staleness: 85
Complexity: 40
Confidence: 75
Support Request: 10
close stale Issue requests prioritizing `--use-lxd` CLI flag over `CRAFT_BUILD_ENVIRONMENT` env var for local vs container execution. Currently inactive for over a year, awaiting triage/implementation.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 20
Confidence: 80
Support Request: 0
needs triage Bug where --use-lxd CLI flag fails to override CRAFT_BUILD_ENVIRONMENT=host, causing commands to run locally instead of in LXD. Currently untriaged and inactive for over a year.
qwen3.6-35b-a3b-mtp-q6
Staleness: 95
Complexity: 20
Confidence: 75
Support Request: 0
close stale Ensure --use-lxd overrides CRAFT_BUILD_ENVIRONMENT to force LXD builds. Issue is open, unassigned, and awaiting implementation. Last activity over a year ago.

Update history

No update history recorded yet.

Related work

  • Related To: snapcraft#4329 (confidence 90%)

    Merged PR in snapcraft that fixed the same precedence issue for SNAPCRAFT_BUILD_ENVIRONMENT vs --use-lxd; confirms the fix is feasible but was not applied to craft-application.

  • Related To: snapcraft#4832 (confidence 85%)

    Same problem reported in snapcraft; fixed by PR #4329, issue still open.

  • Related To: snapcraft#4307 (confidence 80%)

    Same precedence problem reported in snapcraft.

Related issues

Issue Project State Summary Similarity
#4832 `SNAPCRAFT_BUILD_ENVIRONMENT` takes priority over `--use-lxd` snapcraft open 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.
78%
#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.
71%
#1805221 Build environment with lxd (--use-lxd) snapcraft (launchpad) closed The proposal to implement a --use-lxd flag for build environments was closed without discussion or implementation. The feature remains unimplemented and the request was abandoned.
71%