rushstack
rushstack copied to clipboard
[rush] Provide a "rush remove" command that undoes "rush add"
Hello!
The npm has the uninstall command to remove installed dependencies both from the manifest and from the filesystem.
I really miss this in Rush.
Thanks!
Could you give a little more information about your use case?
How would this feature be different from manually deleting the library from package.json and then running rush update or rush update --full?
@octogonz If manually deleting a library from package.json is the recommended path then why even bother with rush add and rush install commands?
A command doing one thing which should be reversible should have a reversible counterpoint:
rush install->rush uninstallrush add->rush remove
The main benefit of rush add is that it (1) figures out the right version number and (2) makes sure it's consistent with other projects across the repo.
* `rush install` -> `rush uninstall`
The way to undo rush install is rush purge. I feel like that name more accurately describes this operation.
* `rush add` -> `rush remove`
This seems pretty reasonable, as an alternative to manually deleting the entry from package.json. Maybe it could have some other features like deleting from all projects at once. (?)
We'd accept a PR for rush remove if someone wants to contribute one.
I think a rush remove command is sorely needed.
In the short term you can manually achieve the same outcome by deleting the line in the package.json and running rush update --recheck. This saw the packages being removed from the pnpm lock file for me.
I ended up on this thread because I intuitively assumed that rush remove would exist.
If I remove a package directly from package.json (in my case: "@mikro-orm/postgresql": "~4.5.9") then run rush update I get this error:
ERR_PNPM_LOCKFILE_MISSING_DEPENDENCY Broken lockfile: no entry for '/@mikro-orm/core/4.5.9_@[email protected]' in pnpm-lock.yaml
Edit:
After getting this error. If I reintroduce the line in package.json and run rush update again, it seems to re-download all the deps:
Progress: resolved 984, reused 0, downloaded 968, added 981, done
I get the same error as @ByScripts when removing a package from package.json
So what's the proper way to remove a package?
I am also very pro-adding a rush remove command that undoes rush add.
@genu to answer your question, the only simple workaround for this that I see is this order of commands:
** First, manually revert any updated package.json files (remove the added lines for the package in question), then run:
rush purge; #this clears out all deps files
rush update #this reinstalls all deps per the package.json files, now excluding the package in question
I just want to add a reason for adding rush remove: It is more intuitive
I went to rush docs to find how to remove a dependency, didn't find out how, and then I had to search about it just to get here on this issue. If we had a command people would see it on the "help" command or on the menu of the website.
I need rush remove causing dependencies should not update manually.
+1
In the short term you can manually achieve the same outcome by deleting the line in the
package.jsonand runningrush update --recheck. This saw the packages being removed from the pnpm lock file for me.
Not for me.
I am also very pro-adding a
rush removecommand that undoesrush add.@genu to answer your question, the only simple workaround for this that I see is this order of commands:
** First, manually revert any updated package.json files (remove the added lines for the package in question), then run:
rush purge; #this clears out all deps files rush update #this reinstalls all deps per the package.json files, now excluding the package in question
And not for me.
Did change some integrity hashes, though.
I can't believe there's no proper way to remove a dependency.
+1
+1
Could you give a little more information about your use case?
How would this feature be different from manually deleting the library from package.json and then running
rush updateorrush update --full?
The deleted package is still in common/config/rush/npm-shrinkwrap.json file. If I run rush purge and then rush update, I get Integrity check failed error.
I need to manually delete npm-shrinkwrap.json which will lose other package versions. What if I do not want to accidentally update other package versions? Can I run rush update --package one-package
One command is always better :)
@octogonz i am working on this,here is my pr !3588, The error of ci doesn't seem to have anything to do with my changes
Closing - requested functionality introduced in #3588. 🎉