-
Notifications
You must be signed in to change notification settings - Fork 615
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
[rush] Install fails if multiple versions of peer dependency with strictPeerDependencies #1415
Comments
The common/temp/package.json {
"dependencies": {
"@azure/amqp-common": "1.0.0-preview.6",
"@rush-temp/core": "file:./projects/core.tgz",
"@rush-temp/project1": "file:./projects/project1.tgz",
"@rush-temp/project2": "file:./projects/project2.tgz"
},
"description": "Temporary file generated by the Rush tool",
"name": "rush-common",
"private": true,
"version": "0.0.0"
} As you say, Now, The implicitly preferred project2/package.json {
"name": "project2",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@azure/amqp-common": "1.0.0-preview.6",
"rhea-promise": "^0.1.15"
}
} That package.json has the right WorkaroundFor your isolated repro at least, the workaround is pretty easy: We can simply EXPLICITLY prefer the version, by adding a setting like this: common/config/rush/common-versions.json {
"$schema": "https://developer.microsoft.com/json-schemas/rush/v5/common-versions.schema.json",
"preferredVersions": {
"rhea-promise": "^0.1.15"
},
"allowedAlternativeVersions": {
}
} This tells Rush that Root causeThis is arguably a Rush bug, however. (It's probably specific to Rush+PNPM; the NPM/Yarn node_modules semantics are arguably too weak to say that Rush did anything wrong here, nor is strictPeerDependencies validation even realistic for their model.) Anyway, ideally Rush+PNPM should not implicitly prefer a dependency that would create an unsatisfied peer. The fix is to improve the implicitly preferred versions logic:
This sounds easy, but there's a hitch: The @azure/amqp-common/package.json comes from the NPM registry, so its But there's also a simple fix:
I'd be interested to try such an option and see how it affects the pnpm-lock.yaml for serious monorepos. I know that in large monorepos people definitely use the explicitly preferred versions feature, and implicitly preferred versions reduced the need for that, but we didn't study it very formally, especially with the latest PNPM. If someone wants to work on this, the relevant Rush code is in InstallManager.collectImplicitlyPreferredVersions(). |
@octogonz: We have hit another issue with
Attempted workaround in
|
I think another workaround should be to pin
|
The |
This is fixed in |
The Unfortunately I was sick this week and am a little swamped catching up, so I don't have time to investigate it right away. @mikeharder Maybe you could try an experiment? Go into this file: And right after those lines, add Also make sure you have Then redo your If not I promise to investigate this more, since we really want these edge cases to work correctly. |
@octogonz: We have one more repro which might be yet another variation of this issue: https://github.com/mikeharder/rush-peer-dependencies/tree/amqp In short, there are two projects with these dependencies:
Running
If you try to use the
Then
Do you think there is any fix or workaround for this, other than setting CC: @KarishmaGhiya |
@octogonz: Adding Can you please add an option to Rush to trigger the |
- karma-webpack has a peer dependency on webpack - The missing dependency was being masked by a Rush feature "implicitlyPreferredVersions" - We are planning to disable this rush feature (to address other issues) which requires adding this missing dependency - microsoft/rushstack#1415
Awesome, yep I'll start a PR asap |
- karma-webpack has a peer dependency on webpack - The missing dependency was being masked by a Rush feature "implicitlyPreferredVersions" - We are planning to disable this rush feature (to address other issues) which requires adding this missing dependency - microsoft/rushstack#1415
@mikeharder Here's a PR: #1618 |
@octogonz: I am trying to verify this PR in our repo but currently hitting an error related to a missing peer dependency. Investigating... |
…29835) This reverts commit 11da215. Unfortunately, rush does not play well with peerDeps and I am bumping into microsoft/rushstack#1415 I really wanted this to work but rather than continue going down this path I think it's safer to revert and find an alternative given the issues with rush and pnpm
Rush fails to update or install dependencies when multiple packages attempt to use different versions of a peer dependency.
To repro, clone https://github.com/mikeharder/rush-peer-dependencies and run
rush update
, which fails with:Note that
pnpmOptions.strictPeerDependencies
is set totrue
. If this option is changed tofalse
, a warning is printed duringrush update --full
, but the generated lockfile looks valid andrush install
seems to work fine.However, I believe the dependencies in this repo are valid. Both
project1
andproject2
specify matching versions of their dependency and peer dependency:https://github.com/mikeharder/rush-peer-dependencies/blob/05203c08c2358e6fe7843226cf6cdeffe21eba1f/project1/package.json#L12-L13
https://github.com/mikeharder/rush-peer-dependencies/blob/05203c08c2358e6fe7843226cf6cdeffe21eba1f/project2/package.json#L12-L13
Note that
project1
depends oncore
which is another project in this repo, whileproject2
depends on@azure/amqp-common
which is a package from npmjs.com.core
has a peer dependency on packagerhea-promise@^1.0.0
, while@azure/amqp-common
has a peer dependency on packagerhea-promise@^0.1.5
.So this issue might only repro if one package with the peer dependency is in the repo, while the other package is pulled from npmjs.com. I tried to repro with both dependencies in the repo, but this seemed to work fine:
https://github.com/mikeharder/rush-peer-dependencies/tree/peer-dependency-in-own-project
Possibly related discussion: pnpm/pnpm#1142
5.10.3
(latest)3.6.0
(latest)10.16.0
(latest LTS)The text was updated successfully, but these errors were encountered: