Looking for something like gem list
within an RVM gemset but to have it ignore gems in the global and default gemsets so I can see, easily, exactly what gems are in the active gemset (and only the active gemset).

- 64,767
- 30
- 146
- 239

- 37,979
- 50
- 195
- 293
3 Answers
for global:
rvm @global do gem list
for other gemsets:
GEM_PATH=$GEM_HOME gem list
@global
is a gemset that all other gemsets inherit for given ruby, it does not inherit for m itself so it's safe to select it and run gem list
in it's context.
For all other gemsets you can use the fact that gem list
displays gems from all paths available in GEM_HOME
and GEM_PATH
, resetting GEM_PATH
to be equal GEM_HOME
will make only one path available - the one from GEM_HOME
so gem list
will only show gems in the selected gemset, ignoring all other gemsets (at this time the @global
, but RVM 2.0 will support multiple gemsets inheritance).

- 52,729
- 14
- 121
- 158
-
but if you re-assign `GEM_PATH` for this then won't you have to set it back afterwards?!? – Meltemi Sep 06 '12 at 22:40
-
1no, because it's part of one command, this assignment takes effect only for this command, you could prefix it all with `env` just to be sure: `env GEM_PATH=$GEM_HOME gem list` – mpapis Sep 06 '12 at 22:55
Simplest way to do it is to use bash command which show list of directories in your current gemset directory
$ ls `rvm gemdir`/gems

- 2,935
- 1
- 18
- 22
-
2works! what's going on there? I'm not familiar with `\`` on the command line. – Meltemi Sep 06 '12 at 19:53
-
`ls` just lists directory content taking your current gemset dir as argument. Gemset dir is taken from `rvm gemdir` command with appended `/gems` (it's the place where all gem folders live). 8) – Nick Kugaevsky Sep 06 '12 at 20:01
-
1ya familiar with `ls`, etc. but hadn't seen the use of `\`` to enclose a *variable?* or *expression?* before... – Meltemi Sep 06 '12 at 20:49
-
1Backticks help to run enclosed command _before_ running main. And give result of _backticked?_ command to main. – Nick Kugaevsky Sep 06 '12 at 20:52
First, whenever any other gemset is selected, the default (no-name) gemset's contents become invisible.
As you know, effectively the @global gemset is included in all other gemsets for the currently selected Ruby normally.
However, to see the contents of a gemset, excluding the @global gemset, first do rvm use 2.0.0@some-gemset --ignore-gemsets
(or similar for other Rubies) then gem list
.
Similarly to see the contents of the @global gemset, first do rvm use 2.0.0@global
then gem list
.
And similarly to see the contents of the default gemset, do rvm use 2.0.0 --ignore-gemsets
then gem list
.
BTW, you can select a gemset to be the (so-called) default for new (non-login) shells (and I always do so in .bash_profile
, etc. separately for each Ruby interpreter) but that is another kind of default gemset, not the (unnamed) default gemset above.

- 1,994
- 18
- 27
-
Thanks. The "problem" I'm trying to solve is related to `gem update`/`bundle update`. I'd like it, when run, to only update gems within the gemset that they currently reside. I have some gems in `global` and others in `some-gemset`. When I run `gem update` from `some-gemset` it updates ALL gems (incl. `global`) into `some-gemset`. What I do now, every time I update, is switch to `global` first and `gem update` THEN switch to `some-gemset`. Workable but it gets squirrely when you add Gemfiles and Bundler to the mix... – Meltemi Jun 07 '13 at 00:42
-
Quicker is `(rvm use 2.0.0@some-gemset --ignore-gemsets; gem update)`. For Bundler, it's `(rvm use 2.0.0@some-gemset --ignore-gemsets; bundle update)`. But if you want Bundler to install some (not all) new gems into @global, that's difficult. – MarkDBlackwell Jun 07 '13 at 14:33
-
Thank you! :) this solves my issue! spent almost 5 hours on this already. – Kleber S. Jun 27 '14 at 15:35