2017-05-26 34 views
2

我想爲我的項目安裝docker。我曾嘗試安裝Actionpack 5.0.2,但它對我沒有任何好處。我正在關注如何設置的教程,所以我認爲有版本問題。當我運行碼頭工人,組成了起來,這就是我得到:如何解決錯誤「打包程序找不到兼容版本的寶石X」

Bundler could not find compatible versions for gem "actionpack": 
    In Gemfile: 
    rails (~> 5.0.2) ruby depends on 
    actionpack (= 5.0.2) ruby 

    actionpack (>= 5.1.1, ~> 5.1) ruby 

這裏是我的Gemfile:

source 'https://rubygems.org' 

git_source(:github) do |repo_name| 
    repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") 
    "https://github.com/#{repo_name}.git" 
end 
gem 'devise' 
gem 'bootstrap-sass', '~> 3.3.6' 
gem 'sass-rails', '>= 3.2' 
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 
gem 'rails', '~> 5.0.2' 
# Use sqlite3 as the database for Active Record 
#gem 'sqlite3' 
# Use Puma as the app server 
gem 'puma', '~> 3.0' 
# Use Uglifier as compressor for JavaScript assets 
gem 'uglifier', '>= 1.3.0' 
# Use CoffeeScript for .coffee assets and views 
gem 'coffee-rails', '~> 4.2' 
# See https://github.com/rails/execjs#readme for more supported runtimes 
# gem 'therubyracer', platforms: :ruby 

# Use jquery as the JavaScript library 
gem 'jquery-rails' 
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 
gem 'turbolinks', '~> 5' 
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 
gem 'jbuilder', '~> 2.5' 
# Use Redis adapter to run Action Cable in production 
# gem 'redis', '~> 3.0' 
# Use ActiveModel has_secure_password 
gem 'bcrypt', :platforms => :ruby 

# Use Capistrano for deployment 
# gem 'capistrano-rails', group: :development 

group :development, :test do 
    # Call 'byebug' anywhere in the code to stop execution and get a debugger console 
    gem 'byebug', platform: :mri 
end 

group :development do 
    # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. 
    gem 'web-console', '>= 3.3.0' 
end 

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 
gem 'unicorn', '~> 4.9' 
gem 'pg', '~> 0.18.3' 
gem 'sidekiq', '~> 4.0.1' 
gem 'redis-rails', '~> 4.0.0' 
gem 'actionpack', '~> 5.1', '>= 5.1.1' 

編輯:嘗試完全從Gemfile中取出寶石ActionPack的,造成了碼頭工人的新問題-compose起來:

Bundler could not find compatible versions for gem "actionpack": 
    In Gemfile: 
    rails (~> 5.0.2) ruby depends on 
     actioncable (= 5.0.2) ruby depends on 
     actionpack (= 5.0.2) ruby 

    rails (~> 5.0.2) ruby depends on 
     actioncable (= 5.0.2) ruby depends on 
     actionpack (= 5.0.2) ruby 

    rails (~> 5.0.2) ruby depends on 
     actioncable (= 5.0.2) ruby depends on 
     actionpack (= 5.0.2) ruby 

    rails (~> 5.0.2) ruby depends on 
     actioncable (= 5.0.2) ruby depends on 
     actionpack (= 5.0.2) ruby 

    redis-rails (~> 4.0.0) ruby depends on 
     redis-actionpack (~> 4) ruby depends on 
     actionpack (~> 4) ruby 
ERROR: Service 'drkiq' failed to build: The command '/bin/sh -c bundle install' returned a non-zero code: 6 
+0

嘗試'束update'然後'束install' –

+0

^^號的錯誤信息是相當不言自明的;你有一個依賴不匹配。 –

回答

0

這兩條線在Gemfile是導致依賴性衝突:

gem 'rails', '~> 5.0.2' 
gem 'actionpack', '~> 5.1', '>= 5.1.1' 

~> 5.0.2意味着 「大於5.0.2和小於5.1.0」。

'~> 5.1', '>= 5.1.1'表示「大於5.1.1且小於6.0.0」。

因此存在衝突,並且Bundler無法解析。您需要升級rails或降級actionpack

最簡單的解決方案可能是隻Gemfile刪除actionpack,因爲你並不需要在所有指定。 actionpackrails的依賴項,所以無論如何它都將被安裝。

我也建議你刪除'~> 5.0.2'版本約束上rails,除非你有一個很好的理由來鎖定的版本號。

關於你的第二個錯誤更新:

此錯誤是非常類似於上面;這是不言而喻的。

rails (~> 5.0.2) ruby depends on 
    [...] 
    actionpack (= 5.0.2) ruby 

redis-rails (~> 4.0.0) ruby depends on 
    [...] 
    actionpack (~> 4) ruby 

就像上面,你有一個寶石取決於ActionPack的版本v4.x.x,並且依賴於ActionPack的v5.0.2另一顆寶石。

你需要以某種方式更新/放鬆你的Gemfile版本約束。例如,你可以寫:

gem 'redis-rails', '~> 5.0' 
+0

我刪除了這一行,但它給了我新的依賴性問題。我把它貼在@ RichardAE的答案中。 –

+0

請[更新原始問題](https://stackoverflow.com/posts/44198818/edit)(正確的格式),所以我們都可以看到它。不過,這個錯誤應該很容易理解。 –

+0

是的,謝謝你的建議。 –

2

已指定使用ActionPack的大於或等於5.1:

gem 'actionpack', '~> 5.1', '>= 5.1.1' 

但是Rails 5.0.2是專門鎖定到actionpack 5.0.2的。從Gemfile中刪除上面的行,這是多餘的。

+0

我這樣做,並試圖再次撰寫。輸出: 在Gemfile中: 導軌(〜> 5.0.2)紅寶石取決於 actioncable(= 5.0.2)紅寶石取決於 ActionPack的(= 5.0.2)紅寶石 導軌(〜> 5.0.2)紅寶石取決於 actioncable(= 5.0.2)紅寶石取決於 ActionPack的(= 5.0.2)紅寶石 導軌(〜> 5.0.2)紅寶石取決於 actioncable(= 5.0.2)紅寶石取決於 ActionPack的(= 5.0.2)ruby rails(〜> 5.0.2)ruby取決於 actioncable(= 5.0.2)ruby取決於 actionpack(= 5.0.2)ruby –

+0

爲什麼是不是你不使用最新版本的Rails? – RichardAE

+0

沒有真正的原因。這只是當我生成項目時已經存在的版本。 –

0

顯然你有一個依賴問題。

在你的Gemfile嘗試使用:

gem 'rails', '~> 5.1.0' 
gem 'actionpack', '~> 5.1.1' 
相關問題