Skip to content
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] RushInstallManager ignores autoInstallPeers:false (and npmrc auto-install-peers=false) configuration #4843

Open
davemyersworld opened this issue Jul 22, 2024 · 2 comments · May be fixed by #4845

Comments

@davemyersworld
Copy link
Contributor

Summary

I would like to have a monorepo package that declares a peerDependency, but doesn't install it. Installing it has the effect of causing it to reference that version of the dependency when run within the monorepo. That is incorrect behavior, I want it to never install and always depend on the depending package's installation. (When useWorkspaces is set to true, this works correctly).

When autoInstallPeers is false (via pnpm-config.json or .npmrc, and useWorkspaces is set to false, Rush will incorrectly install all peerDependencies of packages in the monorepo.

Repro steps

See repro repo here

But:

  1. Use pnpm as the package manager
  2. Have useWorkspaces disabled
  3. Have autoInstallPeers:false
  4. Have a monorepo package that has a peerDependency declared

Expected result:
The peerDependency is not listed in the package's node_modules folder
Actual result:
The peerDependency IS listed in he package's node_modules folder

Details

This problem is caused by RushInstallManager's usage of PackageJsonEditor.dependencyList. It adds peerDependencies to the same list as regular dependencies. This makes sense if autoInstallPeers is false, but not when it's true.

I'm going to open a PR with a suggested fix, but I think there should be a case specifically for PNPM & autoInstallPeers:false, that checks for peerDeps and excludes them from being added to the tempDependencies Map.

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@microsoft/rush globally installed version? 5.130.2
rushVersion from rush.json? 5.130.2
useWorkspaces from rush.json? false
Operating system? Mac
Would you consider contributing a PR? Yes
Node.js version (node -v)? 20.15.1
@github-project-automation github-project-automation bot moved this to Needs triage in Bug Triage Jul 22, 2024
@iclanton iclanton changed the title [rush] RushInstallManager ignorse autoInstallPeers:false (and npmrc auto-install-peers=false) configuration [rush] RushInstallManager ignores autoInstallPeers:false (and npmrc auto-install-peers=false) configuration Jul 22, 2024
@iclanton
Copy link
Member

Is there a reason why you can't enable workspaces in your repo?

@iclanton iclanton moved this from Needs triage to Waiting for Author in Bug Triage Jul 22, 2024
@davemyersworld
Copy link
Contributor Author

Is there a reason why you can't enable workspaces in your repo?

Hi @iclanton, Our repository is mature, and we've had difficulty getting a correctly installed & passing build we're confident in when attempting to enable useWorkspaces. We'd like to enable it, but it's not straightforward for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Waiting for Author
2 participants