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

Cannot remove "copy" module #5609

Closed
StephanBijzitter opened this issue Apr 2, 2018 · 6 comments
Closed

Cannot remove "copy" module #5609

StephanBijzitter opened this issue Apr 2, 2018 · 6 comments
Assignees

Comments

@StephanBijzitter
Copy link

What is the current behavior?
The module "copy" cannot be removed by Yarn.

What is the expected behavior?
The module "copy" can be removed by Yarn.

Steps to reproduce

yarn add copy -W
# Success

yarn remove copy -W
# Not enough arguments, expected at least 1.

Please mention your node.js, yarn and operating system version.
Node 6.10.3, Yarn 1.5.1, OS X 10.13.3

@ghost ghost assigned rally25rs Apr 2, 2018
@ghost ghost added the triaged label Apr 2, 2018
@StephanBijzitter
Copy link
Author

The following workaround exists:

  1. Remove "copy": "x.x.x" manually from package.json
  2. Run yarn to clean up node_modules and regenerate yarn.lock

@rally25rs
Copy link
Contributor

Seems to work if I try to reproduce it:

~/Projects/yarn-test 🐒   yarn remove copy -W
yarn remove v1.5.1
[1/2] Removing module copy...
[2/2] Regenerating lockfile and installing missing dependencies...
success Uninstalled packages.
✨  Done in 0.78s.

OSX Sierra (bash)
Node 8.10
Yarn 1.5.1

@StephanBijzitter
Copy link
Author

StephanBijzitter commented Apr 2, 2018

Hmm, maybe it is the order or the fact that I added it to devDependencies. I assumed these were irrelevant, but I may as well have been wrong.

This is exactly how I did it, and I can still reproduce it. To make no further assumptions, the companyname-lambda directory name contains [a-z0-9] in place of companyname. I highly doubt that's relevant... but I don't want to make assumptions again :-D

stephans-mbp:companyname-lambda stephanbijzitter$ yarn add --dev -W copy
yarn add v1.5.1
[1/5] 🔍  Validating package.json...
[2/5] 🔍  Resolving packages...
[3/5] 🚚  Fetching packages...
[4/5] 🔗  Linking dependencies...
[5/5] 📃  Building fresh packages...
success Saved lockfile.
success Saved 8 new dependencies.
info Direct dependencies
└─ copy@0.3.1
info All dependencies
├─ copy@0.3.1
├─ frontend-release-maker@1.0.0
├─ gateway-credentials@1.0.0
├─ github-release-maker@1.0.0
├─ image-gateway@1.0.0
├─ companyname-lambda-deployment@1.0.0
├─ resize@1.0.0
└─ translations-sync@1.0.0
✨  Done in 3.35s.
stephans-mbp:companyname-lambda stephanbijzitter$ yarn remove --dev -W copy
yarn remove v1.5.1
error An unexpected error occurred: "Not enough arguments, expected at least 1.".
info If you think this is a bug, please open a bug report with the information provided in "/Users/stephanbijzitter/companyname-lambda/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/remove for documentation about this command.

The "dependencies" listed below info All dependencies (aside form copy) are the workspace modules.

Edit:
Yeah, yarn remove copy -W --dev does work. Seems that the order (in the command) for adding dependencies is less strict than it is for removing them.

@rally25rs
Copy link
Contributor

Huh, interesting observation. Parameter parsing in general is a complete nightmare. I was in that section of code last weekend trying to do some refactoring and cleanup, and ended up reverting because it's way too hairy 😞 I'll tag this as a bug. Thanks for finding it! 👍

@rally25rs
Copy link
Contributor

Ah you know what, I think this is a variant of #2600 - we use commander.js to parse our args, and it seems to ignore any arguments that come after an invalid/unknown arg.

Both -D/--dev and -W/--ignore-workspace-root-check are valid flags for yarn add but are not flags for remove (run yarn help remove and those flags are not listed) so after commander.js parses it, it's basically the same as running yarn remove (with no other args)

It works if the flags are after the package name because commander.js does put the package name in the parameters before ignoring the unknown flags.

I wonder if those 2 flags should be added to yarn remove 🤔

I'm going to close this issue, and I opened #5611 to track adding a -W flag to remove. Yarn not warning about the unrecognized parameters is part of #2600

@StephanBijzitter
Copy link
Author

Good to know! Thanks for taking a look.

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

No branches or pull requests

2 participants