rbenv wrong gem version in installation directory

Viewed 686

I've been struggling with this for a while now. I want to use ruby-2.4.1 in my application and installed rbenv and also installed 2.4.1 with it.

I can confirm that ruby -v prints out 2.4.1 is being used.

gem env leads to the following:

RubyGems Environment:
             - RUBYGEMS VERSION: 2.6.11
- RUBY VERSION: 2.4.1 (2017-03-22 patchlevel 111) [x86_64-darwin18]
- INSTALLATION DIRECTORY: /Users/thementoria/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0
- USER INSTALLATION DIRECTORY: /Users/thementoria/.gem/ruby/2.4.0
- RUBY EXECUTABLE: /Users/thementoria/.rbenv/versions/2.4.1/bin/ruby
- EXECUTABLE DIRECTORY: /Users/thementoria/.rbenv/versions/2.4.1/bin
- SPEC CACHE DIRECTORY: /Users/thementoria/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/thementoria/.rbenv/versions/2.4.1/etc
- RUBYGEMS PLATFORMS:
    - ruby
- x86_64-darwin-18
- GEM PATHS:
    - /Users/thementoria/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0
- /Users/thementoria/.gem/ruby/2.4.0
- GEM CONFIGURATION:
    - :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
    - https://rubygems.org/
    - SHELL PATH:
    - /Users/thementoria/.rbenv/versions/2.4.1/bin
- /usr/local/Cellar/rbenv/1.1.1/libexec
- /Users/thementoria/.rbenv/bin
- /Users/thementoria/.rbenv/shims
- /usr/local/bin
- /usr/bin
- /bin
     - /usr/sbin
- /sbin
     - /usr/local/MacGPG2/bin

Note that my USER INSTALLATION DIRECTORY, INSTALLATION DIRECTORY and GEM PATHS have 2.4.0 in it.

What causes this to happen?

In my .bashrc I have:

eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/bin:$PATH"

Any help would be appreciated.

1 Answers

All is fine. Ruby assumes that all gems within a minor version are fully compatible.

This is probably based on a 20 year old decision which would allow you to transfer installed gems within patch versions of Rubies, by simply copying or symlinking them, without downloading them again. I doubt that the same decision would be made today.

Related