← Back to issue list

Some variables aren't properly set

View original Github issue

Metadata

Project
snapcraft
Number
#4704
Type
issue
State
closed
Author
dilyn-corner
Labels
Created
Updated
Closed

Current evaluation

Fixed via PR #4757 by correctly setting architecture variables for core24 cross-architecture builds. CRAFT_PROJECT_NAME and CRAFT_PROJECT_VERSION remain unprocessed and are tracked separately in craft-application issue #320.

Suggested action:

No scores available.

Issue body

### Bug Description When building a core24 snap for a different architecture, the `BUILD_FOR` variables are set to the host architecture instead of the target. This might be similar to #4702 ### To Reproduce Install snapcraft from `latest/edge` (tested with revision 11178) `snapcraft`, `snapcraft --build-for riscv64`, and `snapcraft --build-for=riscv64` all fail to set the correct architecture. Curiously, `snapcraft --build-for amd64` returns no errors but also doesn't do anything (no-op with no message?) but that may be unrelated. ### Environment Snapcraft on a 23.10 host building with `--use-lxd`. ### snapcraft.yaml ```shell name: my-snap-name # you probably want to 'snapcraft register <name>' base: core24 # the base snap is the execution environment for this snap build-base: devel version: '0.1' # just for humans, typically '1.2+git' or '1.3.2' summary: Single-line elevator pitch for your amazing snap # 79 char long summary description: | This is my-snap's description. You have a paragraph or two to tell the most important story about your snap. Keep it under 100 words though, we live in tweetspace and your description wants to look good in the snap store. grade: devel # must be 'stable' to release into candidate/stable channels confinement: devmode # use 'strict' once you have the right plugs and slots platforms: riscv64: build-on: [amd64, riscv64] build-for: [riscv64] parts: my-part: # See 'snapcraft plugins' plugin: nil override-build: | echo BUILD_FOR is "${CRAFT_ARCH_BUILD_FOR}" echo BUILD_ON is "${CRAFT_ARCH_BUILD_ON}" echo TRIPLET_BUILD_FOR is "${CRAFT_ARCH_TRIPLET_BUILD_FOR}" echo TRIPLET_BUILD_ON is "${CRAFT_ARCH_TRIPLET_BUILD_ON}" echo PROJECT_NAME is "${CRAFT_PROJECT_NAME}" echo PROJECT_VERSION is "${CRAFT_PROJECT_VERSION}" ``` ### Relevant log output ```shell Starting snapcraft, version 8.0.5.post149+git2fd36174 Logging execution to '/home/dilyn/.local/state/snapcraft/log/snapcraft-20240329-130845.515502.log' Starting snapcraft, version 8.0.5.post149+git2fd36174 Logging execution to '/home/dilyn/.local/state/snapcraft/log/snapcraft-20240329-130845.515502.log' Launching managed ubuntu devel instance... Starting instance Starting snapcraft, version 8.0.5.post149+git2fd36174 Logging execution to '/tmp/snapcraft.log' Starting snapcraft, version 8.0.5.post149+git2fd36174 Logging execution to '/tmp/snapcraft.log' Initialising lifecycle Installing build-packages Installing build-snaps Skipping pull for my-part (already ran) Building my-part :: + echo BUILD_FOR is amd64 :: BUILD_FOR is amd64 :: + echo BUILD_ON is amd64 :: BUILD_ON is amd64 :: + echo TRIPLET_BUILD_FOR is x86_64-linux-gnu :: TRIPLET_BUILD_FOR is x86_64-linux-gnu :: + echo TRIPLET_BUILD_on is x86_64-linux-gnu :: TRIPLET_BUILD_ON is x86_64-linux-gnu :: + echo PROJECT_NAME is my-snap-name :: PROJECT_NAME is my-snap-name :: + echo PROJECT_VERSION is 0.1 :: PROJECT_VERSION is 0.1 Staging my-part Priming my-part Packing... Reading snap metadata... Running linters... Running linter: classic Running linter: library Creating snap package... Packed my-snap-name_0.1_riscv64.snap ``` ### Additional context Also of note: `SNAPCRAFT_PROJECT_{NAME,VERSION}` are invalid variables (though their `CRAFT_` counterparts *are* valid), which means the [documentation](https://snapcraft.io/docs/parts-environment-variables#heading--snapcraft-configuration-core22) is incorrect. `SNAPCRAFT_PROJECT_GRADE` and `CRAFT_PROJECT_GRADE` are never replaced and both raise an unbound variable error, but I think these things are more related to #4702 than this bug.

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.6-35b-a3b Fixed via PR #4757 by correctly setting architecture variables for core24 cross-architecture builds. CRAFT_PROJECT_NAME and CRAFT_PROJECT_VERSION remain unprocessed and are tracked separately in craft-application issue #320.
qwen/qwen3.6-35b-a3b Fixed via PR #4757. Architecture setup method extracted and applied to core24 projects, resolving incorrect BUILD_FOR assignments. CRAFT_PROJECT_NAME and CRAFT_PROJECT_VERSION remain unevaluated and tracked in craft-application#320.
qwen/qwen3.6-35b-a3b Fixed via PR #4757. Core24 BUILD_FOR variables now correctly target the specified architecture. CRAFT_PROJECT_NAME and CRAFT_PROJECT_VERSION evaluation remains unresolved and tracked separately.
qwen3.6-35b-a3b-mtp-q6 Fixed via PR #4757 by correctly setting architecture variables for core24 builds. CRAFT_PROJECT_NAME and CRAFT_PROJECT_VERSION evaluation remains unresolved and is tracked in craft-application issue #320.
qwen3.6-35b-a3b-mtp-q6 Fixed via PR #4757. BUILD_FOR variables now correctly set to the target architecture for core24 snaps. CRAFT_PROJECT_NAME and CRAFT_PROJECT_VERSION evaluation remains unresolved and is tracked separately.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#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.
77%
#4757 fix: set project variables for core24 snapcraft merged Merged a fix setting CRAFT_PROJECT_NAME and CRAFT_PROJECT_VERSION variables for core24 snaps. Approved by two reviewers, passed CI, and resolved issues #4704 and #4702.
73%
#4770 Wrong arch being used in core24 project variables snapcraft closed The CRAFT_ARCH_TRIPLET_BUILD_FOR variable incorrectly used the host architecture instead of the target when using --build-for on core24. The bug was resolved and merged via pull request #4779.
72%