berry icon indicating copy to clipboard operation
berry copied to clipboard

[Bug?]: yarn install fails during 'Post-resolution validation' after upgrade to 4.0

Open eigilsagafos opened this issue 1 year ago โ€ข 5 comments

Self-service

  • [ ] I'd be willing to implement a fix

Describe the bug

After upgrading to yarn 4 and running yarn install I get the following error:

โžค YN0000: โ”Œ Post-resolution validation
โžค YN0001: โ”‚ TypeError: Cannot read properties of null (reading 'set')
    at /.yarn/releases/yarn-4.0.0.cjs:140:118086
    at Array.map (<anonymous>)
    at sM (/.yarn/releases/yarn-4.0.0.cjs:140:118074)
    at /.yarn/releases/yarn-4.0.0.cjs:207:6475
    at Array.map (<anonymous>)
    at FAt (/.yarn/releases/yarn-4.0.0.cjs:207:6070)
    at /.yarn/releases/yarn-4.0.0.cjs:213:2771
    at Lt.startSectionPromise (/.yarn/releases/yarn-4.0.0.cjs:176:2834)
    at Lt.startTimerPromise (/.yarn/releases/yarn-4.0.0.cjs:176:3734)
    at St.install (/.yarn/releases/yarn-4.0.0.cjs:213:2697)

To reproduce

This is a huge private monorepo. I'm aware that this might get closed due to no way to reproduce, but I am posting in case others have the same issue and could add more context.

Note: The doc link in this issue template to https://yarnpkg.com/advanced/sherlock is broken

Environment

System:
    OS: macOS 14.0
    CPU: (10) arm64 Apple M1 Max
  Binaries:
    Node: 19.9.0 - /private/var/folders/1h/8llh51vx1s1g998jrmj8_qg80000gn/T/xfs-68ee2d4f/node
    Yarn: 4.0.0 - /private/var/folders/1h/8llh51vx1s1g998jrmj8_qg80000gn/T/xfs-68ee2d4f/yarn
    npm: 9.6.3 - ~/.local/share/nvm/v19.9.0/bin/npm

Additional context

No response

eigilsagafos avatar Oct 24 '23 13:10 eigilsagafos

Hm - can you try running yarn set version from sources --no-minify to have a more readable stacktrace and be able to add console.log around the relevant lines?

arcanis avatar Oct 24 '23 13:10 arcanis

@arcanis I'm working on it and will update soon.

Another sidenote, it worked to get the non minified version, however the install ends with an error

Unknown Syntax Error: Unsupported option name ("--no-minify").

$ ... <pluginName>
โžค YN0001: Child yarn reported an error
โžค YN0001:   Exit Code: 1
โžค YN0000: Failed with errors in 42s 368ms

eigilsagafos avatar Oct 24 '23 14:10 eigilsagafos

So the problem was that we have been using workspace:packages/name some places instead of workspace:* (I don't remember why we have been using that pattern, but it worked in yarn 3). The validRange function returned ["workspace:packages/name"] in the simplifyRanges function resulting in the crash. I was able to complete the install without errors when I changed all the internal package references to workspace:*.

eigilsagafos avatar Oct 24 '23 14:10 eigilsagafos

Hello I'm having the same problem. Basically, we have two monorepos and I'd like to link packages from one monorepo to another using yarn link /path/to/package/in/monorepo --all

After a quick investigation the error occurs here https://github.com/yarnpkg/berry/blob/017b94ae4eb20dea14ac673a053a1f2974b778ff/packages/yarnpkg-core/sources/semverUtils.ts#L207

I can try to reproduce the issue

MrDockal avatar Nov 23 '23 14:11 MrDockal

Having the same issue here we are not using the workspace:packages/name

izifortune avatar Jan 09 '24 20:01 izifortune

I just run into this as well. I patched Yarn to add some debug logging to see if I can trace down what's happening.

In my code, I was programmatically using Yarn (as part of the monoweave project). In monoweave, we update the version ranges in the package.jsons and then call:

await project.install({
    cache,
    report,
    immutable: false,
})

it ends up there was a bug in monoweave which caused one of the dependency ranges to be set to a value which produced peer dependency warnings. In emitPeerDependencyWarnings, we collect ranges and pass them to simplifyRanges which ultimates passes each range to validRange:

https://github.com/yarnpkg/berry/blob/2aa53d144c2e0fed8792032ce8655a34116a15f7/packages/yarnpkg-core/sources/Project.ts#L2652C11-L2652C20

one of the peer dependency ranges being passed in was a workspace protocol: workspace:1.2.3. This was converted to "null" via validRange which caused the error.

In my case, once I fixed my invalid peer dependencies, the error went away. This does seem to imply some sort of bug or lack of error handling in the emitPeerDependencyWarnings function though.

Full stack trace (semverUtils.js:188 points to validRange).

Post-resolution validation
โžค YN0001: โ”‚ TypeError: Cannot read properties of null (reading 'set')
    at /home/runner/.yarn/berry/cache/@yarnpkg-core-patch-09dbe5b5d6-10.zip/node_modules/@yarnpkg/core/lib/semverUtils.js:188:63
    at Array.map (<anonymous>)
    at Object.simplifyRanges (/home/runner/.yarn/berry/cache/@yarnpkg-core-patch-09dbe5b5d6-10.zip/node_modules/@yarnpkg/core/lib/semverUtils.js:188:33)
    at /home/runner/.yarn/berry/cache/@yarnpkg-core-patch-09dbe5b5d6-10.zip/node_modules/@yarnpkg/core/lib/Project.js:1982:43
    at Array.map (<anonymous>)
    at emitPeerDependencyWarnings (/home/runner/.yarn/berry/cache/@yarnpkg-core-patch-09dbe5b5d6-10.zip/node_modules/@yarnpkg/core/lib/Project.js:1969:100)
    at /home/runner/.yarn/berry/cache/@yarnpkg-core-patch-09dbe5b5d6-10.zip/node_modules/@yarnpkg/core/lib/Project.js:1305:13
    at StreamReport.startSectionPromise (/home/runner/.yarn/berry/cache/@yarnpkg-core-patch-09dbe5b5d6-10.zip/node_modules/@yarnpkg/core/lib/StreamReport.js:239:26)
    at StreamReport.startTimerPromise (/home/runner/.yarn/berry/cache/@yarnpkg-core-patch-09dbe5b5d6-10.zip/node_modules/@yarnpkg/core/lib/StreamReport.js:289:21)
    at Project.install (/home/runner/.yarn/berry/cache/@yarnpkg-core-patch-09dbe5b5d6-10.zip/node_modules/@yarnpkg/core/lib/Project.js:1302:27)
โžค YN0000: โ”‚ โ”” Completed

noahnu avatar Mar 08 '24 03:03 noahnu

~/opencti# yarn install โžค YN0000: ยท Yarn 4.1.1 โžค YN0000: โ”Œ Resolution step โžค YN0000: โ”” Completed in 0s 719ms โžค YN0000: โ”Œ Post-resolution validation โžค YN0060: โ”‚ graphql is listed by your project with version 16.8.1, which doesn't satisfy what graphql-import (p73478) and other dependencies request (^14.0.2 || ^15.0.0). โžค YN0086: โ”‚ Some peer dependencies are incorrectly met; run yarn explain peer-requirements for details, where is the six-letter p-prefixed code. โžค YN0000: โ”” Completed โžค YN0000: โ”Œ Fetch step โžค YN0000: โ”” Completed in 1s 8ms โžค YN0000: โ”Œ Link step โžค YN0000: โ”” Completed in 1s 90ms โžค YN0000: ยท Done with warnings in 3s 382ms root@ossfergal:~/opencti# yarn explain peer-requirements p73478 We have a problem with graphql, which is provided with version 16.8.1. It is needed by the following direct dependencies of workspaces in your project:

โœ˜ graphql-import@npm:1.0.2 [5bd70] (via ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0) โœ˜ merge-graphql-schemas@npm:1.7.8 [5bd70] (via ^0.11.7 || ^0.13.0 || ^14.0.2 || ^15.0.0)

However, those packages themselves have more dependencies listing graphql as peer dependency:

โœ˜ apollo-utilities@npm:1.3.4 [1a50b] (via ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0) โœ˜ apollo-link@npm:1.2.14 [f3e6e] (via ^0.11.3 || ^0.12.3 || ^0.13.0 || ^14.0.0 || ^15.0.0) โœ˜ apollo-link-http-common@npm:0.2.16 [f3e6e] (via ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0) โœ˜ graphql-tools-fork@npm:9.0.1 [5883f] (via ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0-rc) โœ˜ @graphql-toolkit/common@npm:0.10.3 [8ad33] (via ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0) โœ˜ @graphql-toolkit/graphql-tag-pluck@npm:0.10.3 [8ad33] (via ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0) โœ˜ @graphql-toolkit/code-file-loader@npm:0.10.3 [75c79] (via ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0) โœ˜ @graphql-toolkit/core@npm:0.10.3 [75c79] (via ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0) โœ˜ @graphql-toolkit/graphql-file-loader@npm:0.10.3 [75c79] (via ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0) โœ˜ @graphql-toolkit/json-file-loader@npm:0.10.3 [75c79] (via ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0) โœ˜ @graphql-toolkit/schema-merging@npm:0.10.3 [75c79] (via ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0) โœ˜ @graphql-toolkit/url-loader@npm:0.10.3 [75c79] (via ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0) โœ˜ apollo-upload-client@npm:13.0.0 [8de27] (via 14 - 15) โœ˜ @graphql-toolkit/common@npm:0.10.4 [ec2a5] (via ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0) โœ˜ graphql-tools@npm:5.0.0 [ec2a5] (via ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0) โœ˜ @graphql-toolkit/file-loading@npm:0.10.4 [bd61a] (via ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0) โœ˜ @graphql-toolkit/schema-merging@npm:0.10.4 [bd61a] (via ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0)

Put together, the final range we computed is ^14.0.2 || ^15.0.0 root@ossfergal:~/opencti# yarn explain peer-requirements p73478

oupencti avatar Apr 02 '24 14:04 oupencti

I'm still seeing this issue in yarn 4.3.0.

I was on 3.5.1 and upgraded to 4.3.0

I didn't get a chance to dig in deeper, let me know if that's needed.

After running yarn set version from sources --no-minify here's the stack trace

โžค ยท Yarn 4.3.0-git.20240610.hash-f1edfae
โžค โ”Œ Resolution step
โžค โ”‚ + octokit@npm:3.1.2, typescript@patch:typescript@npm%3A5.4.5#optional!builtin<compat/typescript>::version=5.4.5&hash=5adc0c, @octokit/app@npm:14.1.0, @octokit/auth-app@npm:6.1.1, @octokit/auth-oauth-app@npm:7.1.0, and 35 more.
โžค โ”‚ - @octokit/app@npm:13.1.2, @octokit/auth-app@npm:4.0.9, @octokit/auth-oauth-app@npm:5.0.5, @octokit/auth-oauth-device@npm:4.0.4, @octokit/auth-oauth-user@npm:2.1.1, @octokit/auth-token@npm:3.0.3, and 26 more.
โžค โ”‚ TypeError: Cannot read properties of null (reading 'set')
    at /<redacted>/.yarn/releases/yarn-4.3.0-git.20240610.hash-f1edfae.cjs:30895:65
    at Array.map (<anonymous>)
    at simplifyRanges (/<redacted>/.yarn/releases/yarn-4.3.0-git.20240610.hash-f1edfae.cjs:30895:33)
    at applyVirtualResolutionMutations (/<redacted>/.yarn/releases/yarn-4.3.0-git.20240610.hash-f1edfae.cjs:53185:54)
    at Project.resolveEverything (/<redacted>/.yarn/releases/yarn-4.3.0-git.20240610.hash-f1edfae.cjs:53851:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /<redacted>/.yarn/releases/yarn-4.3.0-git.20240610.hash-f1edfae.cjs:54422:13
    at async StreamReport.startSectionPromise (/<redacted>/.yarn/releases/yarn-4.3.0-git.20240610.hash-f1edfae.cjs:45184:20)
    at async Project.install (/<redacted>/.yarn/releases/yarn-4.3.0-git.20240610.hash-f1edfae.cjs:54421:11)
    at async /<redacted>/.yarn/releases/yarn-4.3.0-git.20240610.hash-f1edfae.cjs:137716:9
โžค โ”” Completed in 3m 56s
โžค ยท Failed with errors in 3m 56s

filipw01 avatar Jun 13 '24 15:06 filipw01