rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

[rush] Provide a "rush remove" command that undoes "rush add"

Open slavafomin opened this issue 6 years ago • 17 comments
trafficstars

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!

slavafomin avatar Aug 14 '19 10:08 slavafomin

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 avatar Aug 16 '19 05:08 octogonz

@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 uninstall
  • rush add -> rush remove

olivierlacan avatar May 21 '20 16:05 olivierlacan

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.

octogonz avatar May 22 '20 02:05 octogonz

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.

kierans avatar Feb 05 '21 12:02 kierans

I ended up on this thread because I intuitively assumed that rush remove would exist.

sgup avatar Nov 01 '21 21:11 sgup

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

ByScripts avatar Nov 02 '21 17:11 ByScripts

I get the same error as @ByScripts when removing a package from package.json

So what's the proper way to remove a package?

genu avatar Mar 16 '22 04:03 genu

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

brandonmcconnell avatar Apr 07 '22 19:04 brandonmcconnell

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.

melanke avatar Apr 11 '22 17:04 melanke

I need rush remove causing dependencies should not update manually.

leohxj avatar Apr 12 '22 14:04 leohxj

+1

RickCardoso avatar May 10 '22 14:05 RickCardoso

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.

Not for me.

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

And not for me.

Did change some integrity hashes, though.

I can't believe there's no proper way to remove a dependency.

nbcarey avatar May 24 '22 21:05 nbcarey

+1

nightmareT avatar Jun 23 '22 02:06 nightmareT

+1

Aiden-FE avatar Jul 07 '22 02:07 Aiden-FE

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?

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

paulz-swyftx avatar Jul 14 '22 05:07 paulz-swyftx

One command is always better :)

piotrkosyoo avatar Jul 31 '22 07:07 piotrkosyoo

@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

sherlockfeng avatar Aug 16 '22 11:08 sherlockfeng

Closing - requested functionality introduced in #3588. 🎉

elliot-nelson avatar Nov 29 '22 10:11 elliot-nelson