← 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

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.

Suggested action: close stale

Reason: The issue is 3499 days old with zero comments and no maintainer interaction. It targets snapcraft/plugins/nodejs.py, but the current repo layout has no snapcraft/plugins/ directory (only snapcraft/parts/ and snapcraft/extensions/), indicating the legacy nodejs plugin was removed in the core20+ parts-based rewrite. The referenced code path no longer exists, so the issue is no longer applicable.

Impact: 25 Quick Win: 17.5 Staleness: 95 Complexity: 30 Confidence: 70 Support Request: 10

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
qwen/qwen3.8-27b
Impact: 25
Quick Win: 17.5
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.
qwen3.6-35b-a3b-mtp-q6
Staleness: 98
Complexity: 35
Confidence: 90
Support Request: 10
close stale snapcraft's nodejs plugin uses --cache-min=Infinity for npm, blocking cache refresh and causing build failures when dependencies update. Open, unassigned, and awaiting triage. A fix is needed that preserves offline build capabilities.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#1841618 snapcraft should run apt-get update snapcraft (launchpad) open Feature request (2019) for snapcraft to refresh stale apt-get caches in process containers to avoid build failures. Open ~7 years with zero comments, no labels, no maintainer response; no general cache-refresh logic found in the build path.
72%
#1819804 nodejs plugin: build fails if there are missing peer dependencies. snapcraft (launchpad) open Snapcraft nodejs plugin build fails when npm ls --json exits non-zero on missing peer deps; the CalledProcessError fallback is dead code since run_output wraps it in SnapcraftPluginCommandError. Open 7.5 years, unlabelled, no maintainer activity.
72%
#1886858 nodejs plugin doesn't set npm path for custom node version snapcraft (launchpad) open Bug: snapcraft's nodejs plugin downloads a custom nodejs-version but still runs build commands with the default node, leaving npm out of PATH. Reporter supplied a PATH workaround. 6 years old, no labels, zero comments, no maintainer response; nodejs plugin since deprecated/removed.
70%