Snapcraft not verbose enough when missing architecture on plataforms
Metadata
Current evaluation
Resolved by canonical/craft-application#437. Snapcraft now outputs a clear error message recommending users check the platforms declaration or build parameters when the execution environment lacks a matching architecture.
Suggested action: —
No scores available.
Issue body
### Bug Description
I recently faced an issue where the snapcraft was simply not building on arm64 without an apparent reason. In the end it was because it was missing some information in the metadata (snapcraft.yaml)
Also the [documentation](https://snapcraft.io/docs/reference-architectures#core24) is not clear and says:
> The platform name describes a build-on/build-for pairing. If the platform name is a valid debian architecture, then build-on and build-for can be omitted (see below for details).
> See [here](https://snapcraft.io/docs/reference-architectures#heading--supported-architectures) for a list of supported architectures.
> The recommended platform name is build-for arch.
The `here` link is broken and from my interpretation, the build-on and the build-for cannot be omitted (at least if there is something already declared like amd64)
IMO there are some things that needs clarification:
1. It seems that works fine if `platforms` is not declared at all, but if at least one arch is declared, than building on another arch fails
2. I think the ideal scenario would be to be able to build even with this "half declarative" way that the snapcraft yaml was, but at least having a warning message saying that once some arch is declared, the others won't work would be helpful for the users have a better clue what is going on
### To Reproduce
Have a snapcraft.yaml file that has the following content (without arm64):
```
platforms:
amd64:
build-on: [amd64]
build-for: [amd64]
```
And try to build the snap on a arm64 machine.
### Environment
Ubuntu 22.04 LTS using snapcraft on latest/stable channel
### snapcraft.yaml
```yaml
name: dcgm
base: core24
adopt-info: dcgm-exporter
summary: Snap for NVIDIA DCGM and DCGM exporter
license: Apache-2.0
contact: solutions-engineering@lists.canonical.com
description: |
This snap includes NVIDIA DCGM and DCGM exporter to provide GPU monitoring via Prometheus metrics.
platforms:
amd64:
build-on: [amd64]
build-for: [amd64]
grade: stable
confinement: strict
source-code: https://github.com/canonical/dcgm-snap
issues: https://github.com/canonical/dcgm-snap/issues
title: NVIDIA DCGM
apps:
dcgm-exporter:
command: bin/dcgm-exporter
plugs:
- network-bind
- opengl
dcgmi:
command: usr/bin/dcgmi
plugs:
- network-bind
- opengl
nv-hostengine:
command: run_nv_hostengine.sh
plugs:
- network-bind
- opengl
daemon: simple
restart-condition: on-abort
environment:
DCGM_HOME_DIR: "${SNAP_COMMON}"
dcgmproftester10:
command: usr/bin/dcgmproftester10
dcgmproftester11:
command: usr/bin/dcgmproftester11
dcgmproftester12:
command: usr/bin/dcgmproftester12
parts:
wrapper:
plugin: dump
build-packages:
- wget
- dpkg
source: snap/local
override-pull: |
craftctl default
./configure_sources.sh
override-build: |
craftctl default
chmod +x run_nv_hostengine.sh
dcgm-exporter:
after:
- wrapper
plugin: go
stage-packages: [datacenter-gpu-manager=1:3.3.7]
build-snaps:
- go
source: https://github.com/NVIDIA/dcgm-exporter.git
source-type: git
source-tag: 3.3.7-3.5.0
# override build to set custom csv file
override-build: |
craftctl default
mkdir -p $SNAPCRAFT_PART_INSTALL/etc/dcgm-exporter
cp etc/default-counters.csv etc/dcp-metrics-included.csv $SNAPCRAFT_PART_INSTALL/etc/dcgm-exporter/
# override prime to set version
override-prime: |
craftctl default
# Locate dcgm .deb file
DEB_FILE=$(ls $HOME/parts/dcgm-exporter/stage_packages/datacenter-gpu-manager_*.deb)
# Extract the version from the .deb file
DCGM_VERSION=$(dpkg-deb -f "$DEB_FILE" Version)
# Set the Snap version to the same as dcgm deb file
craftctl set version="${DCGM_VERSION#1:}"
layout:
/etc/dcgm-exporter:
symlink: $SNAP/etc/dcgm-exporter
```
### Relevant log output
```shell
This is the [logs](https://github.com/canonical/dcgm-snap/actions/runs/10836527295/job/30070483459) that will show up:
Installing Snapcraft plus dependencies
Ensuring ubuntu is in the lxd group...
/usr/bin/sudo groupadd --force --system lxd
/usr/bin/sudo usermod --append --groups lxd ubuntu
Installing LXD...
/usr/bin/sudo snap install lxd
lxd (5.21/stable) 5.21.2-2f4ba6b from Canonical** installed
Initialising LXD...
/usr/bin/sudo lxd init --auto
Installed docker related packages might interfere with LXD networking:
/usr/bin/sudo iptables -P FORWARD ACCEPT
Installing Snapcraft...
/usr/bin/sudo snap install --channel stable --classic snapcraft
snapcraft [8](https://github.com/canonical/dcgm-snap/actions/runs/10836527295/job/30070483459#step:4:9).3.3 from Canonical** installed
/usr/bin/sudo -u ubuntu -E snapcraft
Error: No snap files produced by build
```
I don't have now the debug logs right now, but I remember that it was validating the syntax and exit without explanation
```
### Additional context
_No response_
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Resolved by canonical/craft-application#437. Snapcraft now outputs a clear error message recommending users check the platforms declaration or build parameters when the execution environment lacks a matching architecture. | |
| qwen/qwen3.6-35b-a3b | — | — | Resolved by craft-application#437. Snapcraft now displays a clear error recommending users verify the platforms declaration and build parameters when the execution environment lacks a matching architecture. | |
| qwen/qwen3.6-35b-a3b | — | — | Fixed by canonical/craft-application#437. Snapcraft now outputs a clear error recommending users verify the platforms declaration when the build environment lacks a matching architecture. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Resolved by canonical/craft-application#437. Snapcraft now outputs a clear error recommending users adjust the platforms declaration or build parameters when the current architecture is not declared in the project file. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Resolved by canonical/craft-application#437. Snapcraft now outputs a clear error recommending users check the platforms declaration or use --platform/--build-for flags when building on an undeclared architecture, replacing the previous vague failure. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #4214 snapcraft 7.4.3 doesn't adequately complain about non-existent architectures | snapcraft | closed | Fixed in snapcraft 8. Validation now rejects unsupported architecture names and returns a clear error listing valid options, replacing the previous vague build plan mismatch warning. | |
| #1691569 snapcraft fails when specifying 'any' architecture in build packages | snapcraft (launchpad) | closed | Closed without resolution. Snapcraft failed when build packages used the ':any' architecture suffix. The reporter suggested stripping the suffix to match apt behavior, but no fix or pull request was implemented. | |
| #1862256 snapcraft should complain loudly when building base: core20 snap on i386 | snapcraft (launchpad) | closed | Closed as superseded. Improved architecture parsing in snapcraft now correctly rejects unsupported base-architecture combinations, addressing the original request without requiring explicit i386 core20 checks. |