I'm using rbenv, so why are there two Gem paths on my system? (OS X Lion)

Nathan picture Nathan · May 3, 2012 · Viewed 17k times · Source

To clarify, I'm using rbenv to manage my ruby versions. I was under the impression that binaries are managed as shims in their respective ruby version directory.

Here is what my system shows when I run gem environment (I'm excluding the irrelevant parts):

 - GEM PATHS:
     - /Volumes/Data/nathan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1
     - /Volumes/Data/nathan/.gem/ruby/1.9.1

Any reason for having two locations? Curious minds want to know.

Answer

Nathan picture Nathan · May 11, 2012

I think I figured out the answer to this question, so I'll post it.

Rbenv allows for a global and/or local version of ruby. So once a ruby is installed and managed via rbenv, you can declare it as a global ruby version used by your entire system.

Likewise, you can declare a local ruby version within a given directory (ex: a specific rails project).

The .gem file in your home path is used by the global ruby version, where as the one tucked away in the rbenv directory is used by the local ruby version.

Note, you can (for whatever reason) declare a local version that is the same as the global version. In that case, the local version will rely on the gem files that are in the deeper rbenv directory, instead of the ~/.gem directory.