← Back to issue list

Snapcraft does not take the environment variables into account during build

View original Launchpad issue

Metadata

Project
snapcraft (launchpad)
Number
#2002474
Type
issue
State
open
Author
~snorbi
Labels
Created
Updated
Closed

Current evaluation

Environment variables in snapcraft command field not expanded during build, causing pack failure

Suggested action: needs triage

Reason: The issue has no labels, no maintainer response, and no assignee after 1331 days. A maintainer should assess whether this environment variable expansion issue is still relevant to current snapcraft versions.

Impact: 50 Quick Win: 30.0 Staleness: 85 Complexity: 40 Confidence: 40 Support Request: 20

Issue body

snapcraft.yaml: name: test-app version: dev summary: TODO summary description: TODO description base: core22 grade: devel confinement: devmode parts: app-jar: source: ./build/libs/ source-type: local plugin: dump stage-packages: - openjdk-17-jdk # TODO headless? apps: server: command: $JAVA_HOME/bin/java -jar app.jar environment: JAVA_HOME: $SNAP/usr/lib/jvm/java-17-openjdk-amd64 PATH: $JAVA_HOME/bin:$PATH Build output: Cannot pack snap file: Command '['snap', 'pack', '--filename', 'test-app_dev_amd64.snap', '--compression', 'xz', PosixPath('/root/prime'), PosixPath('/root/project')]' returned non-zero exit status 1. (2023/01/09 16:17:11.345666 container.go:215: in snap "test-app": path "$JAVA_HOME" does not exist 2023/01/09 16:17:11.345698 container.go:215: in snap "test-app": path "$JAVA_HOME/bin/java" does not exist 2023/01/09 16:17:11.345702 container.go:215: in snap "test-app": path "$JAVA_HOME/bin" does not exist error: cannot pack "/root/prime": snap is unusable due to missing files) Failed to execute pack in instance. Workaround: the command should not use environment variables. command: usr/lib/jvm/java-17-openjdk-amd64/bin/java -version Discussion: https://forum.snapcraft.io/t/simple-java-application/33429/13

Evaluation history

Date Model Scores Action Summary
qwen3.6-35b-a3b-mtp-q6
Impact: 50
Quick Win: 30.0
Staleness: 85
Complexity: 40
Confidence: 40
Support Request: 20
needs triage Environment variables in snapcraft command field not expanded during build, causing pack failure
qwen/qwen3.6-35b-a3b
Staleness: 95
Complexity: 20
Confidence: 90
Support Request: 90
close not a bug Snapcraft fails to pack due to unexpanded environment variables in the command field. No maintainer response in over 3.5 years. The behavior is expected, as command environment variables are evaluated at runtime, not during the build phase.
qwen/qwen3.6-35b-a3b
Staleness: 95
Complexity: 40
Confidence: 80
Support Request: 10
close stale Snapcraft fails to resolve environment variables in the command field during build. Issue is 3.5 years old with no activity; reporter provided a workaround.
qwen/qwen3.6-35b-a3b
Staleness: 95
Complexity: 40
Confidence: 85
Support Request: 10
close stale Reports snapcraft failing to expand environment variables during pack, causing build failures. Unlabelled, zero comments, and inactive for over 3.5 years. Author provided a hardcoded path workaround.
qwen3.6-35b-a3b-mtp-q6
Staleness: 95
Complexity: 40
Confidence: 85
Support Request: 65
close stale Snapcraft fails to expand environment variables in app commands during build, causing missing path errors. No maintainer response, inactive for over three years.
qwen3.6-35b-a3b-mtp-q6
Staleness: 95
Complexity: 30
Confidence: 80
Support Request: 10
close stale Snapcraft fails to resolve environment variables in app commands during pack, causing build failures. Unlabelled, zero comments, inactive for over three years.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#6025 Snapcraft ignores SNAPCRAFT_BUILD_ENVIRONMENT_* environment variables on MacOS snapcraft open SNAPCRAFT_BUILD_ENVIRONMENT_CPU/MEMORY env vars documented for Multipass VM sizing are ignored on macOS; maintainer confirmed values are hardcoded, fix blocked by upstream craft-providers#531 (open 2+ years). Triaged as enhancement, no progress since Feb 2026.
72%