snapcraft's nodejs plugin does not refresh the global, user cache before installing dependencies
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Snapcraft |
New
|
Undecided
|
Unassigned |
Bug Description
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:/
[2] gvancuts@
* branch master -> FETCH_HEAD
Already up-to-date.
Downloading 'node-v4.
npm ERR! node v4.4.4
npm ERR! npm v2.15.1
npm ERR! code ETARGET
npm ERR! notarget No compatible version found: iotivity-
npm ERR! notarget Valid install targets:
npm ERR! notarget ["0.9.2-
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-
npm ERR! notarget
npm ERR! Please include the following file with any support request:
npm ERR! /home/gvancuts/
Command '['/bin/sh', '/tmp/tmpmchipfnc', 'npm', '--cache-
From Stephen: Consider having the nodejs plugin support per project .npmrc so users can set cache options themselves rather than set via args in the plugin.