简体   繁体   English

如何获得捆绑使用/查看RVM使用的Ruby版本?

[英]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: 关于Ruby版本和RVM,这里有很多问题-我已经浏览了它们,但找不到针对我特定问题的解决方案:

I have RVM installed and setup/configured correctly to the best of my knowledge. 据我所知,我已正确安装和设置/配置了RVM。

$ 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. 对我来说,重要的一行是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. 这让我认为捆绑软件不符合RVM设置使用的红宝石版本。 I'm not sure where I went wrong in my configuration though. 我不确定我的配置哪里出错了。 I have never had an issue with RVM before. 我以前从未遇到过RVM的问题。 Indeed, gem install factory_girl -v '3.6.2' works correctly, but bundle still does not see it afterwards. 的确, gem install factory_girl -v '3.6.2'可以正常工作,但之后捆绑包仍然看不到它。

Output from installing factory_girl manually: 手动安装factory_girl的输出:

$ 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完美搭配?

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

$ rvm --default use 1.9.2

Probably its because you are not using rvm at all. 可能是因为您根本没有使用rvm。 By using gem install, you have installed the gems on your system. 通过使用gem install,您已在系统上安装了gem。 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. 鉴于此,如果您没有以root用户身份安装rvm,则需要在开始使用bundle并安装gem之前设置ruby版本。

The stuff that rvm does its completely transparent to bundle. rvm完全透明地捆绑了这些东西。 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命令使用一些红宝石版本,例如:

rvm use 1.9.2

Then, run bundle install. 然后,运行捆绑安装。 =p = p

Two factors: 两个因素:

  1. do not use sudo it makes use non RVM commands nor the RVM environment used by rubygems 不要使用sudo它使用非RVM命令,也不使用rubygems使用的RVM环境

  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" 检查.bundle/config config-如果它包含PATH / STANDALONE ,它将强制捆绑程序跳过RVM宝石集,并在RVM范围之外的本地目录中使用额外的捆绑程序隔离, bundle install --system应该解决它,如果您使用capistrano捆绑程序集成设置适当的标志set :bundle_flags, "--system"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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