Ruby on rails 如何让bundle使用/查看RVM正在使用的Ruby版本?

Ruby on rails 如何让bundle使用/查看RVM正在使用的Ruby版本?,ruby-on-rails,ruby,rvm,bundler,Ruby On Rails,Ruby,Rvm,Bundler,关于Ruby版本和RVM,这里有很多问题-我已经仔细查看了它们,但找不到解决我具体问题的方法: 据我所知,我已正确安装和设置/配置RVM $ ruby -v ruby 1.9.3p362 (2012-12-25 revision 38607) [x86_64-darwin12.2.0] 但是,在运行bundle安装时,我收到以下消息: $ bundle install Updating http://github.com/rails/prototype_legacy_helper.git Fe

关于Ruby版本和RVM,这里有很多问题-我已经仔细查看了它们,但找不到解决我具体问题的方法:

据我所知,我已正确安装和设置/配置RVM

$ ruby -v
ruby 1.9.3p362 (2012-12-25 revision 38607) [x86_64-darwin12.2.0]
但是,在运行bundle安装时,我收到以下消息:

$ 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.
对我来说,重要的一行是
factory\u girl requires Ruby version>=1.9.2.
,这让我觉得bundle不尊重RVM设置使用的Ruby版本。我不确定我的配置哪里出了问题。我以前从未遇到过RVM的问题。事实上,
gem安装工厂-v'3.6.2'
工作正常,但bundle之后仍然看不到它

手动安装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...

如何让bundle与RVM配合使用?

检查一次,检查完成后,效果良好


$rvm——默认使用1.9.2

可能是因为您根本没有使用rvm。通过使用gem安装,您已经在系统上安装了gems。有鉴于此,如果您没有以root用户身份安装rvm,那么在开始使用bundle和安装gems之前,您需要设置一个ruby版本

rvm所做的事情对bundle是完全透明的。如果使用得当,捆绑包将按预期工作

尝试从你的系统中删除你可能拥有的所有宝石。然后使用rvm命令使用一些ruby版本,如:

rvm use 1.9.2
然后,运行bundle安装=有两个因素:

  • 不要使用
    sudo
    它使用非RVM命令,也不要使用rubygems使用的RVM环境

  • 检查
    .bundle/config
    -如果它包含
    路径
    /
    独立
    它将强制bundler跳过RVM gemset并在RVM范围之外的本地目录中使用额外的bundler隔离,
    bundle安装--系统
    应修复它,如果使用capistrano bundler integration,则需要设置适当的标志
    set:bundle\u flags,“--system”


  • gem install factory_girl-v'3.6.2'的输出是什么?@PauloHenrique我添加了来自该工厂的输出-必须以超级用户的身份运行它。Weel,那么您没有使用rvm。将rvm列表的输出以及plz也放入。