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

yarn prune docs lie #6897

Open
damaon opened this issue Jan 9, 2019 · 5 comments
Open

yarn prune docs lie #6897

damaon opened this issue Jan 9, 2019 · 5 comments
Assignees
Labels

Comments

@damaon
Copy link

damaon commented Jan 9, 2019

Do you want to request a feature or report a bug?

bug

What is the current behavior?

yarn prune v1.13.0
error The prune command isn't necessary. `yarn install` will prune extraneous packages.
info Visit https://yarnpkg.com/en/docs/cli/prune for documentation about this command.

^ This is a lie.

If the current behavior is a bug, please provide the steps to reproduce.

mkdir -p node_modules/foo
cd node_modules/foo
npm init
cd ../..
npx yarn@1.13.0 install

node_modules/foo will still be there

In contrast yarn install --force does remove node_modules/foo.

What is the expected behavior?
You tell me? Either docs should be updated or behaviour of yarn install changed.
According to docs yarn install should prune unnecessary deps.

Why:
I had in project 2 dependencies having foo as dependency. One was pointing to foo as dependency and the other was pointing as optionalDependency. I got rid of one with dependency and I'm using ----ignore-optional on deployment. The thing is the foo dependency wasn't really optional but I detected it a little too late because I still had stale foo in node_modules.

If docs were honest I would simply run rm -rf node_modules before yarn install on deployments to ensure such things don't happen again.

Please mention your node.js, yarn and operating system version.
node 6.14.3, yarn 1.13.0 and macOS sierra

@ghost ghost assigned arcanis Jan 9, 2019
@ghost ghost added the triaged label Jan 9, 2019
@arcanis
Copy link
Member

arcanis commented Jan 9, 2019

Interesting. Yarn has an optimization mechanism that will simply not run the install if it detects that your package.json didn't change. Meaning that when running yarn && yarn, the second one will bailout.

In this case (reproduced by yarn add lodash, removing lodash from the package.json, then running yarn again), it seems there's a bug and Yarn doesn't properly detect that the package disappeared, causing it to bailout instead of running the install. That's weird, I could have sworn it worked before 🤔

@ZendyLim
Copy link

ZendyLim commented May 1, 2019

Any updates on this?
Confirmed this with

  • Node v10.15.3
  • Yarn v1.13.0
  • Ubuntu 18.04

Removing entries from package.json then running yarn install doesn't remove the packages at all

@JohannesRudolph
Copy link

JohannesRudolph commented Mar 23, 2020

I think there's also some merit to keeping the current behavior as is, i.e. many node packages stuff additional folders into node_modules that can be safely kept (e.g. angular's ngcc) between installations.

If you need to prune, you can always run yarn prune manually, no?

Edit: You're absolutely right about the docs being misleading though

@aalong-tr
Copy link

The yarn prune command simply aborts with the error message shared in the original report and didn't seem to have any obvious effect for me. Resorting to yarn install --force instead is not especially obvious. If a standard yarn install run is not going to clean up going forward, a working yarn prune command would be helpful.

@dbackeus
Copy link

dbackeus commented Sep 9, 2020

Please provide a working yarn prune since the implied behaviour of yarn install clearly isn't reliable.

On our CI we cache the node_modules manually and extract the latest cache before running yarn install to install any potentially missing packages.

If manually doing rm -rf node_modules before installing the size is 1.1GB. Meanwhile the cached node_modules directory has bloated to ~2GB.

Running yarn prune currently exits immediately with:

yarn prune v1.22.4
error The prune command isn't necessary. `yarn install` will prune extraneous packages.
info Visit https://yarnpkg.com/en/docs/cli/prune for documentation about this command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants