【问题标题】:How do I get bundle to use/see the version of Ruby that RVM is using?如何让 bundle 使用/查看 RVM 正在使用的 Ruby 版本?
【发布时间】:2013-02-21 13:23:00
【问题描述】:

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

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

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

但是,在运行 bundle install 时,我会收到以下消息:

$ 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.,这让我认为 bundle 不尊重 RVM 设置使用的 ruby​​ 版本。不过,我不确定我的配置哪里出错了。我以前从未遇到过 RVM 的问题。确实,gem install factory_girl -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 配合使用?

【问题讨论】:

  • gem install factory_girl -v '3.6.2' 的输出是什么?
  • @PauloHenrique 我添加了输出 - 必须以超级用户身份运行。
  • Weel,那么你没有使用 rvm。请将 rvm list 的输出也放入 plz。

标签: ruby-on-rails ruby rvm bundler


【解决方案1】:

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

rvm 对捆绑完全透明的东西。如果使用得当,bundle 将按预期工作。

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

rvm use 1.9.2

然后,运行捆绑安装。 =p

【讨论】:

    【解决方案2】:

    两个因素:

    1. 不要使用sudo,它会使用非 RVM 命令或 ruby​​gems 使用的 RVM 环境

    2. 检查.bundle/config - 如果它包含PATH / STANDALONE 它将强制捆绑程序跳过RVM gemsets 并在RVM 范围之外的本地目录中使用额外的捆绑程序隔离,bundle install --system 应该修复它,如果你使用 capistrano bundler 集成你需要设置正确的标志set :bundle_flags, "--system"

    【讨论】:

      【解决方案3】:

      检查一次,做完就可以了

      $ rvm --default use 1.9.2

      【讨论】:

        猜你喜欢
        • 2012-12-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-01-29
        • 1970-01-01
        • 1970-01-01
        • 2019-11-18
        相关资源
        最近更新 更多