Is there a direct way to get the ruby ​​path from rbenv?

I would like to get the path to the gem directory for the current ruby ​​(under rbenv).

This gives me bin dir:

rbenv which ruby

which I could chop and satisfy my needs, but I would like to see if there is anything more direct.

I think that

rbenv prefix

- the best choice. It leaves me with something like

/Users/newalexandria/.rbenv/versions/1.9.3-p448

to which I add

/lib/ruby/gems/1.9.1/gems

I am worried about the gemstones version. I would like to see something better.

+3
source share
2 answers

rbenv exec gem environment returns information about your rubygems installation.

Use it with grep to highlight the directory:

$ rbenv exec gem environment | grep INSTALLATION
> - INSTALLATION DIRECTORY: $HOME/.rbenv/versions/X.X.X-pX/lib/ruby/gems/X.X.X

Here is the complete command:

$ rbenv exec gem environment | grep INSTALLATION | cut -d : -f 2 | xargs
> $HOME/.rbenv/versions/X.X.X-pX/lib/ruby/gems/X.X.X
+5
source

It's here:

/Users/yourname/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems

-1
source

All Articles