![](/img/trans.png)
[英]How do I specify a version of Ruby for Rails without using RVM?
[英]How do I get bundle to use/see the version of Ruby that RVM is using?
关于Ruby版本和RVM,这里有很多问题-我已经浏览了它们,但找不到针对我特定问题的解决方案:
据我所知,我已正确安装和设置/配置了RVM。
$ ruby -v
ruby 1.9.3p362 (2012-12-25 revision 38607) [x86_64-darwin12.2.0]
但是,在运行捆绑安装时,我收到此消息:
$ 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_girl requires Ruby version >= 1.9.2.
这让我认为捆绑软件不符合RVM设置使用的红宝石版本。 我不确定我的配置哪里出错了。 我以前从未遇到过RVM的问题。 的确, gem install factory_girl -v '3.6.2'
可以正常工作,但之后捆绑包仍然看不到它。
手动安装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...
如何获得捆绑包才能与RVM完美搭配?
检查一次,做完后就可以了
$ rvm --default use 1.9.2
可能是因为您根本没有使用rvm。 通过使用gem install,您已在系统上安装了gem。 鉴于此,如果您没有以root用户身份安装rvm,则需要在开始使用bundle并安装gem之前设置ruby版本。
rvm完全透明地捆绑了这些东西。 如果正确使用,则捆绑包将按预期工作。
尝试从系统中删除您可能拥有的所有宝石。 然后使用rvm命令使用一些红宝石版本,例如:
rvm use 1.9.2
然后,运行捆绑安装。 = p
两个因素:
不要使用sudo
它使用非RVM命令,也不使用rubygems使用的RVM环境
检查.bundle/config
config-如果它包含PATH
/ STANDALONE
,它将强制捆绑程序跳过RVM宝石集,并在RVM范围之外的本地目录中使用额外的捆绑程序隔离, bundle install --system
应该解决它,如果您使用capistrano捆绑程序集成设置适当的标志set :bundle_flags, "--system"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.