简体   繁体   中英

Bundler detects wrong version of Ruby

I'm sure this has been asked before, but even after many hours researching I have no idea what could be wrong.

If try to run any bundle command, I get the following error message:

Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0

Yet, the output of ruby-switch --check says otherwise:

Currently using: ruby2.0
------------------------

ruby    -> /usr/bin/ruby2.0
gem -> /usr/bin/gem2.0

and so does the output of rvm list :

rvm rubies

=* ruby-2.0.0-p247 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

and even gem env :

RubyGems Environment:
  - RUBYGEMS VERSION: 2.0.7
  - RUBY VERSION: 2.0.0 (2013-08-29 patchlevel 299) [x86_64-linux-gnu]
  - INSTALLATION DIRECTORY: /var/lib/gems/2.0.0
  - RUBY EXECUTABLE: /usr/bin/ruby2.0
  - EXECUTABLE DIRECTORY: /usr/local/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /var/lib/gems/2.0.0
     - /home/alex/.gem/ruby/2.0.0
     - /usr/share/rubygems-integration/2.0.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/

I'm running Bundler version 1.3.5. Why isn't it recognizing the correct version of Ruby?

All that system ruby information showing up sure makes it seem like RVM is not installed, or is improperly installed. Fixing it sounds like no fun. I'd recommend blowing it away and starting over.

rvm implode
rm -rf ~/.rvm
# check .profile, .bash_profile for remnants of rvm, nuke them too

Then follow the RVM installation instructions to the letter.

Try just installing bundler with gem install bundler after you have run rvm use 2.3.1 or whatever version you wanted to use. Reinstalling RVM for me didn't work (bundler still complained about the wrong version) because the only version of bundler I had was for ruby-2.3.0, and not for ruby-2.3.1. Thus bundle install ran the one version of bundler I had, rather than reporting I didn't have a version of bundler for the ruby version I was using.

Hopefully that can help someone who has also run into this issue when upgrading Ruby.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM