berry: [Bug?]: No candidates found in corporate environment
Self-service
- I’d be willing to implement a fix
Describe the bug
yarn install leads to
➤ YN0000: · Yarn 4.0.1
➤ YN0000: ┌ Resolution step
➤ YN0082: │ @typescript-eslint/scope-manager@npm:6.13.1: No candidates found
➤ YN0000: └ Completed in 9s 219ms
➤ YN0000: · Failed with errors in 9s 235ms
install with 1.22.19 works yarn config gives me
├─ npmRegistryServer
│ ├─ Description: URL of the selected npm registry (note: npm enterprise isn't supported)
│ ├─ Source: /home/myuser/code/myproject/.yarnrc.yml
│ └─ Value: 'https://artifactory.mycompany.net:443/artifactory/api/npm/npm'
yarn npm info @typescript-eslint/scope-manager gives me (excerpt)
{
"name": "@typescript-eslint/scope-manager",
"description": "TypeScript scope analyser for ESLint",
"dist-tags": {
...
"latest": "6.13.1",
...
},
"versions": [
"3.5.0",
...
"6.13.1",
],
"time": {
...
"6.13.1": "2023-11-28T09:36:31.088Z",
...
},
"dist": {
"tarball": "https://artifactory.mycompany.net:443/artifactory/api/npm/npm/@typescript-eslint/scope-manager/-/scope-manager-6.13.1.tgz",
"shasum": "58c7c37c6a957d3d9f59bc4f64c2888e0cac1d70",
"integrity": "sha512-BW0kJ7ceiKi56GbT2KKzZzN+nDxzQK2DS6x0PiSMPjciPgd/JRQGMibyaN2cPt2cAvuoH0oNvn2fwonHI+4QUQ=="
},
"type": "commonjs"
}
To reproduce
I cannot provide, as this only occurs in my company repo I think
Environment
System:
OS: Linux 5.15 Ubuntu 20.04.3 LTS (Focal Fossa)
CPU: (12) x64 Intel(R) Core(TM) i7-9850H CPU @ 2.60GHz
Binaries:
Node: 20.10.0 - /tmp/xfs-d62f7f1e/node
Yarn: 4.0.1 - /tmp/xfs-d62f7f1e/yarn
npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
Additional context
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 10
- Comments: 19 (2 by maintainers)
I’m on 4.02, have the same symptom, and found the root cause (might be different than the original issue posted here). Yarn caches package metadata on disk, and it can get stale when there are newer versions of the package in the registry.
I have the following scenario: Package “x” has versions 1.0.0 and 1.1.0 in the registry. Yarn cached the metadata before 1.1.0 was released, therefore the metadata file cached has latest version 1.0.0 (stale). In my project I have 2 dependencies on package “x”, for both versions.
Yarn first resolves the request for 1.0.0, sees that it has cached metadata on disk that includes this version, and saves this metadata to an internal in-memory cache map. When yarn is resolving 1.1.0, it reads the list of versions directly from the in-memory cache and fails with “No candidates found”
I debugged the code and reached the above conclusion, although I might be wrong.
Deleting the metadata cache (for me it’s in
~/.yarn/berry/metadata/npm) works around this issue.yarn cache clean --all && rm -rf ~/.yarn/berry/metadatafixed the issue for meI am using version 4.4.1 and still have this issue
I see where that comes from, working on a fix.
@ohana54 I’ve looked into one case now in metadata
This version was failing to be installed
and this is the cache of the registry for that package
It is indeed missing two versions that were released after the 26th Nov
The question is, why doesn’t Yarn look into the actual registry for a version that is not in the cached metadata, instead of taking that for a fact?
I’m also getting this error too often with yarn v4.0.x
➤ YN0082: │ @typescript-eslint/scope-manager@npm:6.13.2: No candidates found
I’m constantly getting the same errors with different transitive dependencies too and need to add them explicitly to get around this issue, using Yarn 4.0.2 - see https://stackoverflow.com/questions/77593499/why-does-yarn-fail-with-no-candidates-found-errors
To help any others who find this issue on Windows with
corepackenabled, I found the metadata folder under: “%LOCALAPPDATA%\Yarn\Berry\metadata”Using Git BASH for Windows, it’s possible to use this command to remove the directory…
yarn cache clean --all && rm --recursive --force "$(yarn config get globalFolder)/metadata"Yarn version 4.3.1 the issue still persist, only workaround is to delete the metadata folder. This issue should be reopened, since its the same error.
I use the GitLab private registry, and this issue still persists. Is anyone else experiencing a similar case?
Clearing the cache resolves the issue temporarily, but the same error occurs again the next time I update the package version, requiring me to clear the cache each time.
With @ericis answer I was able to resolve the issue.
yarn config get globalFolderrevealed that in my case yarn used~/.local/share/yarn/berry/metadata/. So for linux users:yarn cache clean --all && rm -rf $(yarn config get globalFolder)/metadataFind it very weird that clearing cache won’t fix the issue either: