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

Running pnpm install with --force flag also installs optionalDependencies which don't match OS in use #6133

Open
mcmxcdev opened this issue Feb 25, 2023 · 9 comments

Comments

@mcmxcdev
Copy link
Contributor

pnpm version: 7.28.0

Code to reproduce the issue:

$ pnpm install --force
 WARN  using --force I sure hope you know what you are doing
Scope: all 4 workspace projects
Lockfile is up to date, resolution step is skipped
Packages: +2505
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Downloading registry.npmjs.org/@swc/core-linux-arm-gnueabihf/1.3.36: 10.8 MB/10.8 MB, done
Downloading registry.npmjs.org/@swc/core-linux-arm64-musl/1.3.36: 13.4 MB/13.4 MB, done
Downloading registry.npmjs.org/@swc/core-linux-arm64-gnu/1.3.36: 13.7 MB/13.7 MB, done
Downloading registry.npmjs.org/@swc/core-darwin-arm64/1.3.36: 12.7 MB/12.7 MB, done
Downloading registry.npmjs.org/@swc/core-darwin-x64/1.3.36: 13.6 MB/13.6 MB, done
Downloading registry.npmjs.org/@swc/core-win32-x64-msvc/1.3.36: 14 MB/14 MB, done
Downloading registry.npmjs.org/@next/swc-linux-arm-gnueabihf/13.1.6: 23.2 MB/23.2 MB, done
Downloading registry.npmjs.org/@swc/core-win32-ia32-msvc/1.3.36: 11.3 MB/11.3 MB, done
Downloading registry.npmjs.org/@next/swc-linux-arm64-musl/13.1.6: 27.1 MB/27.1 MB, done
Downloading registry.npmjs.org/@next/swc-android-arm-eabi/13.1.6: 21.5 MB/21.5 MB, done
Downloading registry.npmjs.org/@next/swc-win32-ia32-msvc/13.1.6: 24 MB/24 MB, done
Downloading registry.npmjs.org/@next/swc-win32-arm64-msvc/13.1.6: 24.6 MB/24.6 MB, done
Downloading registry.npmjs.org/@swc/core-win32-arm64-msvc/1.3.36: 12.2 MB/12.2 MB, done
Downloading registry.npmjs.org/@next/swc-darwin-arm64/13.1.6: 26.4 MB/26.4 MB, done
Downloading registry.npmjs.org/@next/swc-darwin-x64/13.1.6: 27 MB/27 MB, done
Downloading registry.npmjs.org/@next/swc-linux-arm64-gnu/13.1.6: 27.6 MB/27.6 MB, done
Downloading registry.npmjs.org/@next/swc-freebsd-x64/13.1.6: 34.1 MB/34.1 MB, done
Downloading registry.npmjs.org/@next/swc-win32-x64-msvc/13.1.6: 29.6 MB/29.6 MB, done
Downloading registry.npmjs.org/@next/swc-android-arm64/13.1.6: 27 MB/27 MB, done
Progress: resolved 2505, reused 2395, downloaded 95, added 2505, done

Expected behavior:

Usually, only the versions related to Linux are installed for me on a regular install.

Actual behavior:

pnpm downloads all listed optionalDependencies

Additional information:

  • node -v prints: v18.14.1
  • Windows, macOS, or Linux?: Ubuntu 22.10
@mcmxcdev
Copy link
Contributor Author

Oh, it seems this is by design: https://pnpm.io/cli/install#--force

@stevenpetryk
Copy link
Contributor

stevenpetryk commented Aug 11, 2023

I do think it's maybe worth discussing having a different --force that does everything --force currently does except this.

A common workflow when debugging is to make a tiny tweak in node_modules (not necessarily patching), and it'd be useful to be able to get back to a good state without installing all optional dependencies. For example, a workflow like this:

  1. pnpm install
  2. Observe some issue with a dependency, throw some logs casually into the dependency's code
  3. Solve problem
  4. pnpm install --force-without-optionals (or something)

It's cumbersome to make a throwaway patch, and it's breakage-y to install optional deps. Would be great to have a command that is essentially "reset me to a fresh install".

@wtlgo
Copy link

wtlgo commented Mar 22, 2024

4. pnpm install --force-without-optionals

I think pnpm install --force --no-optional would be a very logical way

@stevenpetryk stevenpetryk reopened this Mar 22, 2024
@vdawg-git
Copy link

Maybe not installing optional dependencies would be the default and pnpm install --force --with-optional would also install optional dependencies?

I am not sure why it should install optional dependencies by default, as packages with binaries for other platforms did cause problems for me more than once :D

@sibelius
Copy link

sibelius commented Aug 3, 2024

does

pnpm install --force --no-optional

works ?

@sibelius
Copy link

sibelius commented Aug 3, 2024

can we avoid installing optional from other archs ?

@sibelius
Copy link

sibelius commented Aug 3, 2024

image

how can I avoid this ?

@stevenpetryk
Copy link
Contributor

This issue is pretty well-defined, and some spinoff follow-ups have come in.

@sibelius what you're asking for is what this issue is asking for. pnpm install --force does install optionals. This issue tracks the request to make it not do that anymore.

@pnpm pnpm locked and limited conversation to collaborators Aug 4, 2024
@pnpm pnpm unlocked this conversation Aug 4, 2024
@stevenpetryk
Copy link
Contributor

Sorry, meant to edit the title rather than lock!

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

5 participants