RVM: List all gems in current gemset ignoring global & default
Frage
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).
Lösung
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).
Andere Tipps
Simplest way to do it is to use bash command which show list of directories in your current gemset directory
$ ls `rvm gemdir`/gems
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.