Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

cache-min & unknown version #8581

Closed
timoxley opened this issue Jun 16, 2015 · 8 comments
Closed

cache-min & unknown version #8581

timoxley opened this issue Jun 16, 2015 · 8 comments

Comments

@timoxley
Copy link
Contributor

Currently, if npm is trying to install a package not yet in the npm cache, it will reach out to the registry and grab the package, even with cache-min=Infinity. This is desirable.

This allows high values for cache-min to work well, but a problem occurs in the following scenario:

  1. package A in cache, knows all versions up to v1.0.0.
  2. package A releases version 1.1.0
  3. package B not in cache, gets downloaded
  4. package B requests package A ^1.1.0.
  5. npm install --cache-min=Infinity
  6. npm errors with a "no matching version found" error, listing all versions up to 1.0.0.

To resolve this, one has to update the cache's version info e.g. npm info packagename or lower the cache-min setting. This makes use of high cache-min values particularly error prone, especially on first installs.

It would be good if unknown versions were treated the same as unknown package names, i.e. npm should fall back to checking the remote registry before reporting "no compatible version found".

@timoxley
Copy link
Contributor Author

@othiym23 what are your reservations about this?

@JamesMGreene
Copy link

Arrrrrgh! I keep running into this, too. 😡

e.g.

npm ERR! Linux 3.14.48-33.39.amzn1.x86_64
npm ERR! argv "node" "/usr/local/bin/npm" "install" "--cache-min=Infinity"
npm ERR! node v0.10.38
npm ERR! npm  v2.13.3
npm ERR! code ETARGET

npm ERR! notarget No compatible version found: yargs@'>=3.19.0 <4.0.0'
npm ERR! notarget Valid install targets:
npm ERR! notarget ["1.0.0","1.0.1","1.0.3","1.0.4","1.0.5","1.0.6","1.0.7","1.0.8","1.0.9","1.0.10","1.0.11","1.0.12","1.0.13","1.0.15","1.1.0","1.1.1","1.1.2","1.1.3","1.2.0","1.2.1","1.2.2","1.2.3","1.2.4","1.2.5","1.2.6","1.3.0","1.3.1","1.3.2","1.3.3","2.1.1","2.3.0","3.0.0","3.0.1","3.0.2","3.0.3","3.0.4","3.1.0","3.2.1","3.3.1","3.4.0","3.4.4","3.4.5","3.5.0","3.5.1","3.5.2","3.5.3","3.5.4","3.6.0","3.7.0","3.7.1","3.7.2","3.8.0","3.9.0","3.9.1","3.10.0","3.11.0","3.12.0","3.13.0","3.14.0","3.15.0","3.16.0","3.16.1","3.17.1"]
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 'em'
npm ERR! notarget 

Here, em is a local module, which is also a dependency of another higher-level local module/tool.

@iarna
Copy link
Contributor

iarna commented Feb 19, 2016

We chatted more about this internally and reservations are withdrawn– We would welcome a patch that, if a dependency version lookup failed with a cached version of the package's metdata, tried again with a fresh version. (This may be a bit tricky due to the architecture around the config being a painfully global object, but with sufficient surgery it's plausible.) However, it's not on our timeline for the coming year to add it ourselves.

As such, @othiym23 has marked this patch-welcome, and I'm going to close this issue.

@iarna iarna closed this as completed Feb 19, 2016
Zirak added a commit to Zirak/npm that referenced this issue Mar 26, 2016
When a package is fetched from the cache which cannot satisfy the
version requirements, an attempt to fetch it fron the network is made.

Fix npm#8581.
@timoxley
Copy link
Contributor Author

For the record, I disagree that this issue should be closed, and I disagree with labelling it as a "feature request". It's a race condition bug that sometimes causes a completely valid npm install to fail.

iarna pushed a commit that referenced this issue May 5, 2016
When a package is fetched from the cache which cannot satisfy the
version requirements, an attempt to fetch it fron the network is made.

Fixes: #8581
PR-URL: #12084
Credit: @Zirak
Reviewed-By: @iarna
@apaleslimghost
Copy link
Contributor

Also for the record: this issue was fixed by #12084 which was released in npm 3.9. --cache-min=Infinity to your heart's content.

@gumallett
Copy link

Has there been a regression? We are currently using 3.10.8 and this logic is no longer working. we have cache-min=Infinity and after publishing a new version of a dependency (e.g 1.0.7), running npm install dep@1.0.7 gives an error ETARGET.

@legodude17
Copy link
Contributor

That could be it.
Pinging @timoxley, as well as @iarna and @othiym23.

@alienlike
Copy link

I'm still experiencing this at v4.1.2, with npm update.

$ call npm update --cache-min=Infinity
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\gitlab-runner\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "update" "--cache-min=Infinity"
npm ERR! node v6.2.0
npm ERR! npm  v4.1.2
npm ERR! code ETARGET

npm ERR! notarget No compatible version found: postcss-loader@'>=1.3.0 <2.0.0'
npm ERR! notarget Valid install targets:
npm ERR! notarget 0.1.0, 0.2.0, 0.3.0, 0.4.0, 0.4.1, 0.4.2, 0.4.3, 0.4.4, 0.5.0, 0.5.1, 0.6.0, 0.7.0, 0.8.0, 0.8.1, 0.8.2, 0.9.0, 0.9.1, 0.10.0, 0.10.1, 0.11.0, 0.11.1, 0.12.0, 0.13.0, 1.0.0, 1.1.0, 1.1.1, 1.2.0, 1.2.1, 1.2.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! Please include the following file with any support request:
npm ERR!     c:\GitLab-Runner\builds\bf2143f7\0\xplan\Find-A-Ride\src\FindARide\npm-debug.log

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants