简体   繁体   中英

How do I get bundle to use/see the version of Ruby that RVM is using?

There are a lot of questions on here about Ruby versions and RVM - I've looked through them and can't find a solution to my specific problem:

I have RVM installed and setup/configured correctly to the best of my knowledge.

$ ruby -v
ruby 1.9.3p362 (2012-12-25 revision 38607) [x86_64-darwin12.2.0]

However, when running bundle install, I'm getting this message:

$ bundle install
Updating http://github.com/rails/prototype_legacy_helper.git
Fetching gem metadata from http://rubygems.org/......
Fetching gem metadata from http://rubygems.org/..
Enter your password to install the bundled RubyGems to your system: 
Using rake (10.0.3) 
Using RedCloth (4.2.9) 
Using i18n (0.6.1) 
Using multi_json (1.6.1) 
Using activesupport (3.2.12) 
Using builder (3.0.4) 
Using activemodel (3.2.12) 
Using erubis (2.7.0) 
...

...
Using eventmachine (1.0.0) 
Using excon (0.17.0) 
Installing factory_girl (3.6.2) 
Gem::InstallError: factory_girl requires Ruby version >= 1.9.2.
An error occurred while installing factory_girl (3.6.2), and Bundler cannot continue.
Make sure that `gem install factory_girl -v '3.6.2'` succeeds before bundling.

To me, the important line there is factory_girl requires Ruby version >= 1.9.2. which makes me think that bundle is not respecting the ruby version RVM is set to use. I'm not sure where I went wrong in my configuration though. I have never had an issue with RVM before. Indeed, gem install factory_girl -v '3.6.2' works correctly, but bundle still does not see it afterwards.

Output from installing factory_girl manually:

$ sudo gem install factory_girl -v '3.6.2'
Password:
Successfully installed factory_girl-3.6.2
1 gem installed
Installing ri documentation for factory_girl-3.6.2...
Installing RDoc documentation for factory_girl-3.6.2...

How do I get bundle to play nice with RVM?

检查一次,做完后就可以了

$ rvm --default use 1.9.2

Probably its because you are not using rvm at all. By using gem install, you have installed the gems on your system. Given that, if you didn't installed rvm as root, you need to set a ruby version before start to play with bundle and install gems.

The stuff that rvm does its completely transparent to bundle. If it is properly used, bundle will work as expected.

Try to remove all gems that u may have from your system. Then use the command for rvm to use some ruby version like:

rvm use 1.9.2

Then, run bundle install. =p

Two factors:

  1. do not use sudo it makes use non RVM commands nor the RVM environment used by rubygems

  2. check .bundle/config - if it contains PATH / STANDALONE it will force bundler to skip RVM gemsets and use extra bundler isolation in local directory out of RVM scope, bundle install --system should fix it, if you use capistrano bundler integration you need to set proper flags set :bundle_flags, "--system"

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