snapcraftctl fails, but exit status is zero
Metadata
Current evaluation
Fixed by merged PR #3317 (commit 9c622ecda), which makes snapcraft propagate snapcraftctl build failures instead of returning a false success status.
Resolution: closed resolved
Reason: Commit 9c622ecda, titled "pluginhandler: properly handle snapcraftctl errors (#3317)," fixed the failure propagation. The maintainer linked that PR as the resolution.
Evaluated by: mr-cal-bot
No scores available.
Issue body
I'm porting the grafana snap to core20, and there is an override-build section for the grafana-ui part, which I had to switch to use npm, where `snapcraftctl build` is clearly failing, but still exiting with status 0.
I added some debugging output and this is the summary (see https://pastebin.ubuntu.com/p/5C2hWcYB3b/ for better formatting):
snapcraft yaml snippet:
override-build: |
set -x
# https://forum.snapcraft.io/t/issue-with-nodejs-plugin-when-using-base-keyword/11109/8
#echo "unsafe-perm = true" > ~/.npmrc
rm -rf ~/.npmrc
snapcraftctl build
result=$?
echo "result=$result"
echo "exiting now"
/bin/false
export PYTHON=/usr/bin/python2
...
building with --use-lxd:
Launching a container.
Waiting for container to be ready
Waiting for network to be ready...
snap "snapd" has no updates available
snap "core20" has no updates available
Skipping pull grafana (already ran)
Skipping pull grafana-ui (already ran)
Skipping pull snap-wrappers (already ran)
Skipping build grafana (already ran)
Building grafana-ui
+ rm -rf /root/.npmrc
+ snapcraftctl build
+ [ ! -f /root/parts/grafana-ui/install/bin/node ]
+ tar xzf - -C /root/parts/grafana-ui/install/ --strip-components=1
+ curl -s https://nodejs.org/dist/v12.18.3/node-v12.18.3-linux-x64.tar.gz
+ npm pack .
+ tail -1
npm notice
npm notice 📦 grafana@7.0.4
npm notice === Tarball Contents ===
npm notice 210B .babelrc
....
....
npm notice 7.3kB public/app/features/datasources/state/actions.ts
npm notice 28.9kB public/app/features/explore/state/actions.ts
npm notice+ npm install -g --prefix /root/parts/grafana-ui/install grafana-7.0.4.tgz
npm WARN deprecated popper.js@1.16.1: You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1
npm WARN deprecated core-js@1.2.7: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
> core-js@2.6.11 postinstall /root/parts/grafana-ui/install/lib/node_modules/grafana/node_modules/empower-core/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
sh: 1: node: Permission denied
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/grafana/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN @welldone-software/why-did-you-render@4.0.6 requires a peer of react@>=16.13 but none is installed. You must install peer dependencies yourself.
npm WARN slate-react-placeholder@0.2.9 requires a peer of slate-react@>=0.22.0 but none is installed. You must install peer dependencies yourself.
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! core-js@2.6.11 postinstall: `node -e "try{require('./postinstall')}catch(e){}"`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the core-js@2.6.11 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-10-07T19_03_58_004Z-debug.log
Failed to build 'grafana-ui'.
Recommended resolution:
Check the build logs and ensure the part's configuration and sources are correct.
+ result=0
+ echo result=0
+ echo exiting now
+ /bin/false
result=0
exiting now
You can see I'm hitting the problem described in https://forum.snapcraft.io/t/issue-with-nodejs-plugin-when-using-base-keyword/11109/8, but snapcraftctl doesn't signal it and the build would continue were it not for my /bin/false statement to force a stop.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Fixed by merged PR #3317 (commit 9c622ecda), which makes snapcraft propagate snapcraftctl build failures instead of returning a false success status. | |
| stealth/space-bunny-alpha | — | closed resolved | Fixed snapcraftctl error propagation so failed build/pull commands return nonzero and override scripts stop; merged in canonical/snapcraft#3317 (9c622ecda). | |
| stealth/space-bunny-alpha | — | closed resolved | Fixed snapcraftctl's swallowed build errors in canonical/snapcraft#3317, restoring a nonzero exit status when the underlying build fails. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without resolution. Report described snapcraftctl build returning exit code 0 despite npm failures, but no fix or merge details were provided. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without a fix. snapcraftctl incorrectly returned exit status 0 despite npm failures, requiring a manual workaround. The report was abandoned with no comments or resolution. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without comments or resolution, likely abandoned. The reported bug where snapcraftctl returns exit code zero despite build failures was not addressed or fixed. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Closed without resolution. The report detailed snapcraftctl build returning exit status zero despite underlying npm failures. No fix or developer comments were provided. |
Update history
| Date | Change |
|---|---|
| created |
Related work
-
Likely Fixed By:
snapcraft#3317
(confidence 99%)
The linked fix was merged as commit 9c622ecda.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #3317 plugin handler: properly handle snapcraftctl errors | snapcraft | merged | Merged PR #3317 in commit 9c622ecda, making snapcraftctl exit nonzero on build/pull failures and stop override scripts after parent operation errors. | |
| #1604326 snapcraft init doesn't fail if there is a .snapcraft.yaml file | snapcraft (launchpad) | closed | Fixed by merged snapcraft#669 (commit 2cd727259): snapcraft init now detects an existing .snapcraft.yaml and fails instead of creating snapcraft.yaml. |