Skip to content

fix: correction to the set resolution docs #6739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 28, 2025

Conversation

darren-dooley
Copy link
Contributor

@darren-dooley darren-dooley commented Mar 25, 2025

What's the problem this PR addresses?

The example in the set resolution docs does not work for many packages.
https://yarnpkg.com/cli/set/resolution#examples

Issues

Resolves #5979

Steps to reproduce:

  1. Clone and cd to the yarnpkg/berry repository
  2. Run yarn set resolution lodash@npm:^4.17.11 4.16.0
  3. Observe the following error
yarn set resolution lodash@npm:^4.17.11 4.16.0
➤ YN0000: · Yarn 4.7.0-dev
➤ YN0000: ┌ Resolution step
➤ YN0001: │ Error: [email protected] isn't supported by any available resolver
    at MultiResolver.getResolverByDescriptor (/Users/***/personal/berry/packages/yarnpkg-core/sources/MultiResolver.ts:73:13)
    at MultiResolver.getResolutionDependencies (/Users/***/personal/berry/packages/yarnpkg-core/sources/MultiResolver.ts:37:27)
    at startDescriptorResolution (/Users/***/personal/berry/packages/yarnpkg-core/sources/Project.ts:911:53)
    at <anonymous> (/Users/***/personal/berry/packages/yarnpkg-core/sources/Project.ts:955:57)
    at async startDescriptorAliasing (/Users/***/personal/berry/packages/yarnpkg-core/sources/Project.ts:896:28)
➤ YN0000: └ Completed
➤ YN0000: · Failed with errors in 0s 154ms

How did you fix it?

The fix is to include npm before the resolved version, 4.16.0 -> npm:4.16.0.
The full command will be yarn set resolution lodash@npm:^4.17.11 npm:4.16.0.

Result

Yarn correctly set the resolution in the yarn.lock file as follows:

"lodash@npm:^4.17.11":
  version: 4.16.0
  resolution: "lodash@npm:4.16.0"
  checksum: 10/37d70b8a67edd4f3ef82ba3354de8dc4123ee9eddd84700a69edd3e2e3f8ae8d562162ed5af95d60810c333745c6ded9c8f432d19840387cde071ddcef5c6ec7
  languageName: node
  linkType: hard

Checklist

  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

@clemyan
Copy link
Member

clemyan commented Mar 26, 2025

@yarnpkg/cli also needs a patch because the output of yarn set resolution --help is affected

@clemyan clemyan self-requested a review March 26, 2025 16:21
@arcanis arcanis merged commit 3263f61 into yarnpkg:master Mar 28, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug?]: The command for set resolution has changed in v4
3 participants