I have global gems and various gemsets. I want to remove all gems of a gemset. Is there a way do to this, besides uninstalling the gemset?
Asked
Active
Viewed 6.3k times
7 Answers
263
Use the gemset empty
command:
rvm gemset empty mygems

Andy Lindeman
- 12,087
- 4
- 35
- 36
-
8You need to specify the gemset you want to empty. It's not enough just to "rvm use [gemset_name]". You need to "rvm gemset empty [gemset_name]". – refaelos Nov 29 '11 at 10:22
-
I suppose if you have many gems, it could take a while to uninstall them all. – Andy Lindeman Jun 10 '12 at 21:18
-
14Incidentally right now I am able to run `rvm gemset empty` and it clears the current gemset. – Ibrahim Jan 10 '13 at 05:19
17
This command removes all the ruby gems installed locally in 1-step Works well in Ubuntu 10.10
gem list | cut -d" " -f1 | xargs gem uninstall -aIx
PS - removes all local gems. Use sudo accordingly.

lucapette
- 20,564
- 6
- 65
- 59

Sulabh Jain
- 388
- 3
- 7
-
2gem also has a --no-versions flag, which is nice: `gem list --no-versions | xargs gem uninstall -aIx` – trisweb Nov 20 '12 at 16:32
12
rvm gemset empty <gemset name>
This will remove all gems from your mentioned gemset.

Ramiz Raja
- 5,942
- 3
- 27
- 39
6
rvm gemset empty <gemset>
works, but only if you specify a gemset name.
If you want to empty the default gemset, you need to pass an empty string for the gemset name.
rvm gemset empty mygems ""

Craig Walker
- 49,871
- 54
- 152
- 212
4
Isn't removing all the gems out of a gemset essentially the same operation as deleting a gemset and then adding it back? Why not just do this:
$ rvm gemset mygemset
$ rvm gemset delete mygemset
$ rvm gemset create mygemset

Upgradingdave
- 12,916
- 10
- 62
- 72
-
Yes, essentially it's the same. But I was wondering if there is a way to do this without deleting the gemset. When you delete a gemset, are the gems removed too or are they saved to a cache? – Nerian Jan 14 '11 at 17:02
-
1I'm pretty sure they're completely removed. For example, I have a gemset named `jruby-1.5.6@radiant`. All the gems are located here: `/Users/dparoulek/.rvm/gems/jruby-1.5.6@radiant`. When I do `rvm gemset radiant`, then it warns you to make sure, and then deletes the entire `/Users/dparoulek/.rvm/gems/jruby-1.5.6@radiant` directory. – Upgradingdave Jan 14 '11 at 17:39
-
This would be about the same I guess. I was looking for an alternative because I wanted to remove all the gems from the global gemset so that I could stop new gemsets from "inheriting" the gems from the global gemset. – Moiz Raja Nov 27 '11 at 20:42
2
This is the safest way to uninstalling all gems of a gemset
Step 1
If you gem version is less then 2.1.
gem update --system
gem --version
Step 2
gem uninstall --all

Bhargav Rao
- 50,140
- 28
- 121
- 140

Mukesh Kumar Gupta
- 1,567
- 20
- 15