Bundler发现了错误的ruby版本

时间:2016-11-04 21:10:21

标签: ruby bash bundler activesupport

我使用OS X 10.10.5(约塞米蒂)。我试图为MacDown克隆github repo。自述文件中的说明说,克隆后应该执行

git submodule init
git submodule update
bundle install
bundle exec pod install

我不是红宝石程序员,所以我不得不安装Bundler。前两个步骤运行正常,但当我尝试运行bundle install时出现错误

activesupport-5.0.0.1 requires ruby version >= 2.2.2, which is incompatible with the current version, ruby 2.0.0p481

所以我尝试了brew install ruby,现在我已经

saul@miniMac ✓ ruby --version
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin14]

但是,bundle install给出了与以前相同的错误消息。很明显,它在/usr/bin/ruby找到了红宝石而不是/usr/local/bin/ruby处的红宝石。我该如何纠正?

我想也许问题是我在升级ruby之前安装了bundler,sudo gem uninstall bundlersudo gem uninstall bundle都没有任何效果,我也不知道还有什么可以尝试。

以下是所有输出,如果相关:

saul@miniMac ✓ bundle install
Fetching gem metadata from https://rubygems.org/..........
Fetching version metadata from https://rubygems.org/..
Fetching dependency metadata from https://rubygems.org/.
Resolving dependencies...
activesupport-5.0.0.1 requires ruby version >= 2.2.2, which is incompatible with
the current version, ruby 2.0.0p481

编辑:

感谢您的建议。我再次尝试gem install bundler,但它没有帮助。我收到了同样的错误消息。这是我从bundle env

得到的
saul@miniMac ✗ bundle env
Environment

    Bundler   1.13.6
    Rubygems  2.0.14
    Ruby      2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
    Git       2.5.4 (Apple Git-61)

Gemfile

    source 'https://rubygems.org'

    gem 'cocoapods', '0.39.0'

Gemfile.lock

<No /Users/saul/Projects/macdown/Gemfile.lock found>

编辑2:

saul@miniMac ✓ which -a bundle
/usr/local/bin/bundle
/usr/bin/bundle

1 个答案:

答案 0 :(得分:3)

似乎您的PATH可能有一个指向旧版本Ruby的条目,尽管有更新的版本(2.3.1),它可以使用它在您在其中找到的一个条目中找到的第一个ruby二进制文件PATH,恰好是旧版本。您可以尝试添加最新的Ruby路径作为PATH变量的第一个条目,但是如果运行子shell并且加载了默认的PATH,则会覆盖最新Ruby的路径。话虽这么说,我认为最简单的方法是在这里使用rvm来确保你的环境都是用你想要在任何给定时间使用的版本来设置的。 RVM可以在同一系统中管理多个版本的ruby。阅读更多about RVM here

在同一个终端窗口中运行 all 以下命令:

  1. 安装rvm: curl -sSL https://get.rvm.io | bash -s stable
  2. 将rvm二进制文件添加到PATH: export PATH =&#34; $ PATH:$ HOME / .rvm / bin&#34;
  3. 安装所需的ruby版本: rvm install 2.3.1
  4. 将当前shell配置为使用特定版本的Ruby,如下所示: rvm use 2.3.1
  5. 再次运行捆绑安装