← Back to issue list

SNAPCRAFT_PROJECT_VERSION is empty if not explicitly set at top level

View original Github issue

Metadata

Project
snapcraft
Number
#4231
Type
issue
State
closed
Author
Hook25
Labels
Created
Updated
Closed

Current evaluation

Closed without a code fix. Maintainers explained dynamic environment variables are unsupported, and documentation was updated to clarify that SNAPCRAFT_PROJECT_VERSION only reflects statically set versions.

Suggested action:

No scores available.

Issue body

### Bug Description If the version field is calculated via `adopt-info` instead of explicitly set in the top level version field, the `SNAPCRAFT_PROJECT_VERSION` envvar is empty during the recipe execution (both in `override-build` and in `build-environment`). This is the case even if the step that sets this information (via `snapcraft set-version`) is the first in the recipe. This could either be the intended behavior of this variable, but that is unclear from the documentation and it should, in my opinion, yield a warning, or a bug. ### To Reproduce 1. Create a recipe that sets the version at runtime 2. Use the `SNAPCRAFT_PROJECT_VERSION` anywhere in any subsequent step **Expected:** The environment variable has the set value **Result:** The envvar is empty ### Environment N/A ### snapcraft.yaml ```shell https://github.com/canonical/checkbox/blob/fix_snap_builds_scm/checkbox-core-snap/series22/snap/snapcraft.yaml ``` ### Relevant log output ```shell N/A ``` ### Additional context N/A

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.6-35b-a3b Closed without a code fix. Maintainers explained dynamic environment variables are unsupported, and documentation was updated to clarify that SNAPCRAFT_PROJECT_VERSION only reflects statically set versions.
qwen/qwen3.6-35b-a3b Closed as not a bug. Dynamic environment variables are unsupported due to reliability constraints. Documentation was updated to clarify that SNAPCRAFT_PROJECT_VERSION only reflects statically set versions, not those applied via adopt-info.
qwen/qwen3.6-35b-a3b Closed without code changes. Maintainer declined dynamic environment variable support, citing reliability concerns. Documentation was updated to clarify that SNAPCRAFT_PROJECT_VERSION only reflects statically defined versions.
qwen3.6-35b-a3b-mtp-q6 Closed as documented behavior. Dynamic environment variables are unsupported, so SNAPCRAFT_PROJECT_VERSION only reflects statically set versions. Documentation was updated to clarify this limitation.
qwen3.6-35b-a3b-mtp-q6 Closed as expected behavior. Dynamic environment variables are unsupported due to reliability concerns. Documentation was updated to clarify that SNAPCRAFT_PROJECT_VERSION only reflects statically set versions in snapcraft.yaml.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#1809068 SNAPCRAFT_ environment variables not exposed to version-script snapcraft (launchpad) closed Abandoned and closed without resolution. The missing SNAPCRAFT_ environment variables in version-script were never addressed.
76%
#1923835 $SNAPCRAFT_PROJECT_VERSION isn't working for source once set via snapcraftctl snapcraft (launchpad) closed The bug where $SNAPCRAFT_PROJECT_VERSION fails to propagate in source fields after snapcraftctl set-version was closed without resolution or comments, indicating the report was abandoned.
76%
#1619418 parser needs to replace project level variables snapcraft (launchpad) closed Closed without resolution. The parser was expected to replace SNAPCRAFT_PROJECT_NAME and SNAPCRAFT_PROJECT_VERSION with project name and version values, but the request was abandoned or superseded by later updates.
75%
#4702 [craft-application/core24] $SNAPCRAFT_PROJECT_VERSION and other fields not replaced snapcraft closed Resolved via PR #4757. The core24 variable replacement failure was fixed, though CRAFT_PROJECT_NAME and CRAFT_PROJECT_VERSION remain unevaluated and are tracked separately in craft-application#320.
74%
#1822265 SNAPCRAFT_BUILD_ENVIRONMENT_* change doesn't apply to existing VMs snapcraft (launchpad) closed Closed without resolution. SNAPCRAFT_BUILD_ENVIRONMENT_* changes failing to apply to existing VMs were left unaddressed with zero comments, indicating the report was abandoned or marked stale.
72%
#5491 `${SNAPCRAFT_PROJECT_VERSION}` no longer works in URLs snapcraft closed Regression in Snapcraft 8.9 broke SNAPCRAFT_PROJECT_VERSION and SNAPCRAFT_PROJECT_NAME in URLs. Fixed in Snapcraft 8.9.2 and released to latest/stable and 8.x/stable channels.
71%