npm plugin fails on launchpad
Metadata
Current evaluation
Fixed in canonical/craft-parts#845 (commit fab2ecc1) by making npm plugin setup stateless, restoring npm for Launchpad override-builds.
Resolution: closed resolved
Reason: PR #845 was merged into the craft-parts 1.33.x hotfix line, resolving the npm state loss between Launchpad's pull and build steps.
Evaluated by: mr-cal-bot
No scores available.
Issue body
### Bug Description
since several weeks builds with the npm plugin fail in launchpad when an override-build is used and the `craftctl default` step is executed while working fine locally ...
seemingly it fails on this line where it is calling the "npm --version" command:
https://github.com/canonical/craft-parts/blob/main/craft_parts/plugins/npm_plugin.py#L301
since this happens even before the line after the `craftctl default` is executed there must be some internal thing going wrong. please note that this code used to build reliable about two months ago and a simple re-build now reliably fails.
The source as a fork of the customers code is here:
https://github.com/ogra1/everest-demo/tree/main
### To Reproduce
building locally in an lxd container with --destructive mode as well as building by just calling `snapcraft` and leaving the container handling to snapcraft works well ... as soon as the same code from github is attached to an autobuild on launchpad it fails, probably due to a PATH variable setting missing while extracting the node tarball or some such.
### part yaml
```shell
parts:
nodered:
plugin: npm
source: node-red
npm-include-node: true
npm-node-version: 22.1.0
override-build: |
craftctl default
npm install
mkdir -p $CRAFT_PART_INSTALL/lib
cp -av node_modules $CRAFT_PART_INSTALL/lib/
ln -s ../lib/node_modules/node-red/red.js $CRAFT_PART_INSTALL/bin/node-red
prime:
- -share
```
### Relevant log output
Pull step:
```shell
Pulling nodered
[12/Sep/2024:13:17:02 +0000] "CONNECT nodejs.org:443 HTTP/1.0" 200 16353 "-" "-"
:: + '[' '!' -f /build/everest-demo/parts/nodered/cache/node-v22.1.0-linux-x64.tar.gz ']'
:: + mkdir -p /build/everest-demo/parts/nodered/cache
:: + curl --retry 5 -s https://nodejs.org/dist/v22.1.0/SHASUMS256.txt -o /build/everest-demo/parts/nodered/cache/SHASUMS256.txt
[12/Sep/2024:13:17:02 +0000] "CONNECT nodejs.org:443 HTTP/1.1" 200 10232 "-" "curl/7.81.0"
:: + curl --retry 5 -s https://nodejs.org/dist/v22.1.0/node-v22.1.0-linux-x64.tar.gz -o /build/everest-demo/parts/nodered/cache/node-v22.1.0-linux-x64.tar.gz
[12/Sep/2024:13:17:03 +0000] "CONNECT nodejs.org:443 HTTP/1.1" 200 50739980 "-" "curl/7.81.0"
:: + cd /build/everest-demo/parts/nodered/cache
:: + sha256sum --ignore-missing --strict -c SHASUMS256.txt
:: node-v22.1.0-linux-x64.tar.gz: OK
Pulling edm
```
```shell
building nodered
:: + craftctl default
:: ++ npm --version
:: /build/everest-demo/parts/nodered/run/build.sh: line 5: npm: command not found
:: + NPM_VERSION=
:: error:
:: Traceback (most recent call last):
:: File "/snap/snapcraft/current/lib/python3.10/site-packages/craft_parts/ctl.py", line 111, in main
:: ret = CraftCtl.run(cmd, args)
:: File "/snap/snapcraft/current/lib/python3.10/site-packages/craft_parts/ctl.py", line 45, in run
:: _client(cmd, args)
:: File "/snap/snapcraft/current/lib/python3.10/site-packages/craft_parts/ctl.py", line 98, in _client
:: raise RuntimeError(message)
:: RuntimeError: Failed to run the build script for part 'nodered'.
'override-build' in part 'nodered' failed with code 1.
```
```
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Fixed in canonical/craft-parts#845 (commit fab2ecc1) by making npm plugin setup stateless, restoring npm for Launchpad override-builds. | |
| stealth/space-bunny-alpha | — | closed resolved | Launchpad npm override-build failures were fixed by the stateless npm-plugin change in craft-parts PR #845, merged as fab2ecc1 for the 1.33.x hotfix line. | |
| qwen/qwen3.6-35b-a3b | — | — | Launchpad build failures caused by a missing npm command during craftctl default were resolved. The fix was merged in PR #845 as a hotfix for craft-parts 1.33.x and Snapcraft 8.3.x. | |
| qwen/qwen3.6-35b-a3b | — | — | The npm plugin failed on Launchpad during craftctl default due to a missing npm command. Resolved via a hotfix merged in PR #845 for craft-parts 1.33.x and Snapcraft 8.3.x. | |
| qwen/qwen3.6-35b-a3b | — | — | Resolved in PR #845 by fixing the missing npm command in the build environment during craftctl default. The hotfix was applied to craft-parts 1.33.x for Snapcraft 8.3.x. | |
| qwen/qwen3.6-35b-a3b | — | — | Fixed in PR #845. The npm plugin failed on Launchpad because npm was not found during craftctl default. The hotfix corrects the build environment PATH for craft-parts 1.33.x and Snapcraft 8.3.x. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | npm plugin failed on Launchpad during craftctl default due to missing npm in PATH. Resolved and merged in PR #845 as a hotfix for craft-parts 1.33.x and Snapcraft 8.3.x. |
Update history
No update history recorded yet.
Related work
-
Likely Fixed By:
canonical/craft-parts#845
(confidence 100%)
Merged commit fab2ecc1 made the npm plugin stateless and resolved #844.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #845 fix(plugins): ensure stateless npm plugin | craft-parts | merged | Merged #845 as fab2ecc1, making the npm plugin stateless so Launchpad pull and build steps no longer lose shared state; temporary 1.33-branch fix for #844. | |
| #719 feat(plugin): Refactor NPM plugin | craft-parts | merged | Merged in canonical/craft-parts#719 as 96b33035, refactoring the NPM plugin and fixing #717 by verifying Node.js SHA256 checksums after pull-phase downloads. |