← 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 as intended static behavior: Snapcraft does not dynamically refresh project variables, and the part-environment documentation was clarified on 2023-08-11.

Resolution: closed not a bug

Reason: Maintainer @sergiusens explained that Snapcraft has no reliable dynamic environment-variable updates and confirmed the documentation was clarified to describe the value as the project file's version key. No code fix was made.

Evaluated by: mr-cal-bot

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
stealth/space-bunny-alpha — closed not a bug Closed as intended static behavior: Snapcraft does not dynamically refresh project variables, and the part-environment documentation was clarified on 2023-08-11.
stealth/space-bunny-alpha — closed not a bug Closed as working as designed: SNAPCRAFT_PROJECT_VERSION remains static; documentation now describes it as the version set by the project file's version key.
stealth/space-bunny-alpha — closed not a bug No code fix was made: SNAPCRAFT_PROJECT_VERSION remains static. Documentation was clarified after the maintainer explained that dynamic environment-variable updates are unsupported.
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.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#1923835 $SNAPCRAFT_PROJECT_VERSION isn't working for source once set via snapcraftctl snapcraft (launchpad) closed Closed as expected behavior: SNAPCRAFT_PROJECT_VERSION reflects snapcraft.yaml metadata and is not updated for the current environment by set-version.
77%
#1809068 SNAPCRAFT_ environment variables not exposed to version-script snapcraft (launchpad) closed Closed after maintainers directed users from version-script to snapcraftctl set-version; no fix was cited for the missing SNAPCRAFT_* variables.
75%
#4702 [craft-application/core24] $SNAPCRAFT_PROJECT_VERSION and other fields not replaced snapcraft closed Core24 project-variable replacement was fixed by merged PR #4757 (commit 27957515c). Remaining CRAFT_PROJECT_NAME and CRAFT_PROJECT_VERSION handling was tracked in craft-application#320.
73%
#5491 `${SNAPCRAFT_PROJECT_VERSION}` no longer works in URLs snapcraft closed Regression in Snapcraft 8.9 broke ${SNAPCRAFT_PROJECT_VERSION} (and _NAME) expansion in part sources. Fixed by merged PR #5499 ("fix: evaluate variables in project file", commit abd5db829) and shipped in Snapcraft 8.9.2; issue closed after release announcement by mr-cal.
72%
#1619418 parser needs to replace project level variables snapcraft (launchpad) closed Parser-side substitution of SNAPCRAFT_PROJECT_NAME/VERSION landed via merged PR snapcore/snapcraft#773 (commit 362d6a5f5), closing the Launchpad bug that requested it.
72%
#1216 docs: document custom project vars (SNAPCRAFT-1053) craft-parts closed Closed unmerged after the documentation moved to Snapcraft; canonical/snapcraft#5727 merged the equivalent change in commit cba259a0d.
71%