2016-09-07 109 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