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

pnpm install --filter (to install dependencies only for selected workspace projects) not working with dedupe-peer-dependents set to true #6300

Open
pkerschbaum opened this issue Mar 28, 2023 · 23 comments

Comments

@pkerschbaum
Copy link

pkerschbaum commented Mar 28, 2023

pnpm version:

  • problem present in 8.0.0 with dedupe-peer-dependents not set (thus true = default value of v8.0.0)
  • problem not present in 8.0.0 with dedupe-peer-dependents set to false

Code to reproduce the issue:

https://github.com/pkerschbaum/pnpm-issue-workspaces-no-filter-applied-for-install

Expected behavior:

pnpm install --filter "package-a" should only install dependencies of workspace project package-a.

Actual behavior:

It installs all dependencies.
I tried to also clean the pnpm store before (rm -rf $(pnpm store path)) because I thought maybe pnpm installs more dependencies when they are on the machine already in the store, but even then all dependencies get downloaded&installed.

image

Additional information:

  • node -v prints: v16.19.0
  • Windows, macOS, or Linux?: Ubuntu 22.04.1 LTS
@pkerschbaum pkerschbaum changed the title pnpm install --filter to install dependencies only for selected workspace projects not working pnpm install --filter to install dependencies only for selected workspace projects not working (v8.0.0) Mar 28, 2023
@elclanrs
Copy link

I'm experiencing this bug too. I noticed when I tried to install only root workspace dependencies and it begun installing all dependencies. I also tried clearing node_modules, pnpm store, etc.

pnpm i -w # installs all dependencies in 8.0.0

@zkochan
Copy link
Member

zkochan commented Mar 28, 2023

This is probably happening because this setting is true by default: https://pnpm.io/npmrc#dedupe-peer-dependents

@jazmon
Copy link

jazmon commented Mar 29, 2023

Couldn't the deduping only be applied to what is being installed with the --filter? In our case this setting causes our monorepo install time in the CI to go from 55 seconds to nearly 7 minutes.

@pkerschbaum
Copy link
Author

@zkochan oh right - when I set that setting to false by running pnpm config --location=project set dedupe-peer-dependents=false, the dependencies filter is applied again correctly!
Consequently, this issue might have the same cause as #6264.

Will update issue title and description accordingly...

@pkerschbaum pkerschbaum changed the title pnpm install --filter to install dependencies only for selected workspace projects not working (v8.0.0) pnpm install --filter (to install dependencies only for selected workspace projects) not working with dedupe-peer-dependents set to true Mar 29, 2023
@dvakatsiienko
Copy link

dvakatsiienko commented May 2, 2023

It is happening for me too. #6451
Although, with pnpm install -F='APP_NAME' during deployment to Vercel.

@sawden
Copy link

sawden commented May 2, 2023

I am also facing this issue with pnpm@7.32.2.

@faradaytrs
Copy link

yeah it's still a problem

@nnhjs
Copy link

nnhjs commented Jul 4, 2023

Do we have any updates on this issue? 🤔
I still encountered it in my project, I can't independently run pnpm install on one package in a mono repo.

@AdriVanHoudt
Copy link

It seems like pnpm i --filter=xxx --dedupe-peer-dependents=false fixes the issue indeed.
Would be nice to maybe mention in the docs that this (default) setting "breaks" (depending on how you look at it :P) some expected filters.

@mm-edtake
Copy link

mm-edtake commented Jul 11, 2023

Hi there,
It seems that using pnpm i --filter=xxx --dedupe-peer-dependents=false fixes this issue only if you don't have pnpm-lock file.
Strange behavior because we would like to be able to lock everything for a version but only install needed deps while bundling apps in ci pipelines.
(using v8.6.7)

@nnhjs
Copy link

nnhjs commented Jul 11, 2023

@mm-edtake If you want to use pnpm i --filer=xxx --dedupe-peer-dependents=false in CI I think you can consider some options:

  1. You need to update pnpm-lock.yaml locally with dedupe-peer-dependents=false docs after pushing to GitHub before building.
  • I think this option is good if you can cache .pnpm/store, the time build is less, and trade-offs: we will have several versions of one dependency.
  1. You can disable --frozen-lockfile, read more information here.
  • Easy to build.
  1. Wait for this issue have been resolved.
    I hope it can help you.

@mm-edtake
Copy link

Thanks @nnhjs
I'll wait for this issue to be fixed.
I have options to deal we that so it's ok from my side.

I delete pnpm-lock file before building this specific app so i can then cp all {root}/node_modules to the app bundle (issue #6259)

@verekia
Copy link

verekia commented Jul 25, 2023

As a dirty workaround, you can delete folders of unwanted packages before installing in your CI/CD.
It's not too bad in a simple monorepo where you have client/server/shared code, for instance.
I delete the server folder before the client install, and I delete the client folder before the server install.

@michaelkplai
Copy link

I've also noticed that setting node-linker=hoisted also installs all dependencies even when dedupe-peer-dependents is set to false.

@osdiab
Copy link

osdiab commented Sep 16, 2023

i'm finding on pnpm 8.7.0 pnpm i --filter=xxx --dedupe-peer-dependents=false doesn't work with this error:

ERROR  Unknown option: 'dedupe-peer-dependents'
Did you mean 'strict-peer-dependencies'? Use "--config.unknown=value" to force an unknown option.
For help, run: pnpm help install

Was this flag removed?

@ka2n
Copy link

ka2n commented Sep 16, 2023

@osdiab FYI --config.dedupe-peer-dependents=false would work as same effect.

@osdiab
Copy link

osdiab commented Sep 22, 2023

Thanks for that - it does work then, but yeah due to aforementioned issues from other commenters it doesn't help in CI. Eagerly awaiting this to be resolved, as installs are using up a lot of CI time and therefore costing my company real dollars.

@WhiteKiwi
Copy link
Sponsor Contributor

WhiteKiwi commented Sep 25, 2023

The pnpm filter does not work too if other options such as injected: true & prepare script are turned on, other than depute-peer-dependent
I have checked that the default value of dedupe-peer-dependents is true

KSXGitHub added a commit to pnpm/pnpm.io that referenced this issue Oct 23, 2023
@m1heng
Copy link
Member

m1heng commented Nov 27, 2023

We probably need a notice on doc site to indicate that install --filter is not working as expected with default config, that people need to implicitly set dedupe-peer-dependents to false to have that work.

@khokm
Copy link

khokm commented Feb 24, 2024

UPD: missed that --filter allows you to select dependencies also.
Using -F project... solves my problem.

pnpm -F <project> --config.dedupe-peer-dependents=false i works fine if projects only depends on packages from NPM registry.
If project depends on local packages (i.e. workspace: protocol), it also works.
BUT! If local packages also have dependencies (local or from NPM), they will not be installed.
I.e. package @local/backend depends on @local/client, which depends on axios. axios is not installing, build failed.

@schmod
Copy link

schmod commented Feb 28, 2024

Do we actually understand the root-cause of this issue?

@urbanisierung
Copy link

BUT! If local packages also have dependencies (local or from NPM), they will not be installed.

@khokm what's your approach for this issue? Installing dependencies of local packages manually?

@khokm
Copy link

khokm commented Mar 9, 2024

@urbanisierung i'm just appending an ellipsis i.e. pnpm--filter package-a... i. This installs package-a direct and indirect dependencies and root dependencies also.

Also i feel like my issue is unrelated to this thread, because i don't care about deduplication. I just set dedupe-peer-dependents to false in pnpm config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Priority
Development

No branches or pull requests