2016-09-07 63 views
2

有没有一种方法可以在不指定它的情况下安装最新支持的依赖版本?Force Bundler安装本地Ruby版本支持的gem

我与activesupport宝石有问题。最新版本(5.0.0.1)支持Ruby> = 2.2.2。如果我指定我需要这样的宝石'~> 4.2'即使我在Ruby 2.0上,Bundler也会尝试安装版本5。指定确切版本4.2.7.1或设置最大'~> 4.2', '< 5'作品,使用和Rails宝石5

是否有管理基于当前的Ruby版本的gem版本的方式时除外?

回答

1

显然Bundler的新版本会自动为你做这个。 我从AndréArko找到this comment,提到这已经包含在最新的RC版本中。

我在我的Gemfile中指定了Ruby '2.0',安装Bundler与gem install bundler --pre(它安装了bundler-1.13.0.rc.2),并且bundle install成功安装了activesupport 4.2.7.1。

随着捆扎机1.12.5我收到以下错误:

An error occurred while installing activesupport (5.0.0.1), and Bundler cannot continue. 
0

注意的是,虽然多一点手动,也可以在您的Gemfiles逻辑:

if RUBY_VERSION < "2.2.2" 
    gem "activesupport", "4.2.7.1" 
else 
    gem "activesupport", "5.0.0.1" 
end 
+0

这是一个宝石依赖关系,所以它必须放在gemspec中。 – Sebastian

相关问题