← Back to issue list

snapcraft's nodejs plugin does not refresh the global, user cache before installing dependencies

View original Launchpad issue

Metadata

Project
snapcraft (launchpad)
Number
#1660614
Type
issue
State
open
Author
~gvancuts
Labels
plugins
Created
Updated
Closed
—

Current evaluation

The nodejs plugin's forced npm cache policy was superseded by configurable npm flags in #2038, and the legacy plugin was subsequently moved out in #2984; the issue remains open.

Suggested action: close resolved

Reason: Commit 05b6cdb2f, "nodejs plugin: add option for setting npm flags" (#2038), implemented user-controlled npm flags, superseding the legacy hard-coded cache invocation. Commit 38996d538 (#2984) later moved the plugin out of Snapcraft, so no further action is needed here.

Evaluated by: mr-cal-bot

Impact: 38 Quick Win: 28 Complexity: 18 Confidence: 91 Actionability: 89

Issue body

When using the nodejs plugin of snapcraft, it installs the required package and its dependencies using the "--cache-min" parameter (see [1]). That basically means the npm cache will not be refreshed before attempting the operation and that can result in errors if the following scenario occurs: - Your snap depends on the nodejs "foo" module, initially version 1. - Version 1 of your snap depends on "foo" version 1 and can successfully be built. A few days/weeks later: - You update your snap to version 2 and now require "foo" version 2 But now building your snap fails with an error indicating that "foo" version 2 is not available from the npm registry. That message is confusing because if you check the online npm registry, you will see that it is, in fact, available. The error comes from the fact that 'npm' used an outdated version of the cache that is availabe (and was built before "foo" version 2 was available). For a more complete (and real) error message, see [2] below. A manual workaround is to check the status of the npm cache on your build system (`npm outdated`) and update it (`npm update`) if needed. It would be desirable to remove that option (or find a different mechanism in case snapcraft should also be able to operate offline). [1] https://github.com/snapcore/snapcraft/blob/31c45dd51f73f9065894fda36bc0e339f023418b/snapcraft/plugins/nodejs.py#L133 [2] gvancuts@gvancuts-nuc:~/iot-rest-api-server$ snapcraft Preparing to pull meta-iot-web Pulling meta-iot-web From https://github.com/01org/iot-rest-api-server * branch master -> FETCH_HEAD Already up-to-date. Downloading 'node-v4.4.4-linux-x64.tar.gz'[===========================================================================================================================================================] 100% npm --cache-min=Infinity install npm ERR! Linux 4.4.0-59-generic npm ERR! argv "/home/gvancuts/iot-rest-api-server/parts/meta-iot-web/install/bin/node" "/home/gvancuts/iot-rest-api-server/parts/meta-iot-web/install/bin/npm" "--cache-min=Infinity" "install" npm ERR! node v4.4.4 npm ERR! npm v2.15.1 npm ERR! code ETARGET npm ERR! notarget No compatible version found: iotivity-node@'>=1.2.0-1 <2.0.0' npm ERR! notarget Valid install targets: npm ERR! notarget ["0.9.2-0","0.9.2-1","1.0.0-0","1.0.0-1","1.0.0-2","1.0.0-3","1.0.0-4","1.0.1-0","1.0.1-1","1.1.0-1","1.1.0-2","1.1.0-3","1.1.0-4","1.1.0-5","1.1.1-0","1.1.1-1","1.1.1-2","1.1.1-3","1.2.0-0"] npm ERR! notarget npm ERR! notarget This is most likely not a problem with npm itself. npm ERR! notarget In most cases you or one of your dependencies are requesting npm ERR! notarget a package version that doesn't exist. npm ERR! notarget npm ERR! notarget It was specified as a dependency of 'iot-rest-api-server' npm ERR! notarget npm ERR! Please include the following file with any support request: npm ERR! /home/gvancuts/iot-rest-api-server/parts/meta-iot-web/src/npm-debug.log Command '['/bin/sh', '/tmp/tmpmchipfnc', 'npm', '--cache-min=Infinity', 'install']' returned non-zero exit status 1

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha
Impact: 38
Quick Win: 28
Complexity: 18
Confidence: 91
Actionability: 89
close resolved The nodejs plugin's forced npm cache policy was superseded by configurable npm flags in #2038, and the legacy plugin was subsequently moved out in #2984; the issue remains open.
stealth/space-bunny-alpha
Impact: 48
Quick Win: 24
Complexity: 45
Confidence: 97
Actionability: 90
close resolved Legacy Node.js builds forced a stale npm cache; the current npm implementation no longer passes --cache-min=Infinity, resolving the historical dependency-resolution failure.
stealth/space-bunny-alpha
Impact: 45
Quick Win: 32
Complexity: 20
Confidence: 89
Actionability: 88
close resolved The legacy nodejs plugin forced npm's cache with --cache-min=Infinity, causing stale metadata errors; the plugin has since moved to craft-parts and no longer uses that option.
qwen/qwen3.6-35b-a3b
Impact: 30
Quick Win: 22
Complexity: 10
Confidence: 90
Actionability: 80
close resolved The nodejs plugin's npm cache was not refreshed due to --cache-min=Infinity, causing build failures. The nodejs plugin has been replaced by the npm plugin, which no longer uses this parameter.
qwen/qwen3.8-27b
Impact: 25
Quick Win: 18
Staleness: 95
Complexity: 30
Confidence: 70
Support Request: 10
close stale Legacy snapcraft nodejs plugin used npm --cache-min=Infinity, so a stale npm cache could cause ETARGET build failures when a dependency version was newly published. No maintainer response in ~9.5 years; the legacy plugin no longer exists in current snapcraft.
qwen/qwen3.6-35b-a3b
Staleness: 98
Complexity: 25
Confidence: 95
Support Request: 5
close stale Reports a build failure in snapcraft's legacy nodejs plugin caused by npm cache not refreshing due to --cache-min=Infinity. Inactive for ~9.5 years with no maintainer response.
qwen/qwen3.6-35b-a3b
Staleness: 98
Complexity: 30
Confidence: 90
Support Request: 10
close stale Snapcraft's legacy nodejs plugin uses --cache-min=Infinity, blocking npm cache refresh and causing build failures when dependencies update. Unaddressed for over 9 years.
qwen3.6-35b-a3b-mtp-q6
Staleness: 98
Complexity: 30
Confidence: 90
Support Request: 10
close stale Reports a build failure in snapcraft's nodejs plugin caused by npm's --cache-min=Infinity flag preventing cache refresh. Issue is 9+ years old with no maintainer response or activity.

Update history

Date Change
created

Related work

  • Superseded By: snapcraft#2984 (confidence 97%)

    Commit 38996d538 moved the existing plugins to a new package; current code exposes the successor npm plugin.

  • Likely Fixed By: snapcraft#2038 (confidence 90%)

    Commit 05b6cdb2f added configurable npm flags, directly addressing the request to control cache options.

Related issues

Issue Project State Summary Similarity
#1955887 snapcraft npm doesn't respect npm-node-version snapcraft (launchpad) open Legacy npm configuration was misleading: override-build bypasses the plugin-managed Node download; current craft-parts requires npm-include-node with npm-node-version.
72%