簡體   English   中英

Heroku,bundler 因缺少依賴項而失敗

[英]Heroku, bundler fails on missing dependencies

我最近在嘗試在 Heroku 上部署 Rails 應用時遇到了麻煩。 過去,我在 Heroku 上部署應用程序沒有問題,但 Heroku 不再支持 ruby​​ 2.0.0。 他們建議將ruby "2.2.4"添加到Gemfile ,這就是我所做的。 我的Gemfile開頭如下:

source 'https://rubygems.org'
ruby "2.2.4"

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0'
# Use pg as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
...

所以,我在我的電腦上運行了 1.7.8 版的bundle install沒有問題。 我什至可以在生產模式下運行我的應用程序。 但是,當我嘗試在 Heroku 上部署該應用程序時,我得到了以下信息:

-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.2.4
-----> Installing dependencies using bundler 1.11.2
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
       Fetching gem metadata from https://rubygems.org/...........
       Fetching version metadata from https://rubygems.org/...
       Fetching dependency metadata from https://rubygems.org/..
       Using rake 10.4.2
       Installing i18n 0.7.0
       Installing minitest 5.4.3
       Installing json 1.8.3 with native extensions
       Installing thread_safe 0.3.4
       Installing builder 3.2.2
       Installing erubis 2.7.0
       Your Gemfile.lock is corrupt. The following gem is missing from the DEPENDENCIES
       section: 'mini_portile2'
       Bundler Output: Fetching gem metadata from https://rubygems.org/...........
       Fetching version metadata from https://rubygems.org/...
       Fetching dependency metadata from https://rubygems.org/..
       Using rake 10.4.2
       Installing i18n 0.7.0
       Installing minitest 5.4.3
       Installing json 1.8.3 with native extensions
       Installing thread_safe 0.3.4
       Installing builder 3.2.2
       Installing erubis 2.7.0
       Your Gemfile.lock is corrupt. The following gem is missing from the DEPENDENCIES
       section: 'mini_portile2'
 !
 !     Failed to install gems via Bundler.
 !
 !     Push rejected, failed to compile Ruby app

任何幫助是極大的贊賞。

我建議刪除您的 Gemfile.lock,在本地再次運行bundle install ,將新的 Gemfile.lock 提交到您的 git 存儲庫,然后再次嘗試您的git push heroku master

我遇到了同樣的問題,我所做的是在我的系統中更新了 Ruby 2.2.4 並重新啟動了終端,然后按照以下步驟操作:

bundle install
bundle update 
git push heroku

(最好使用 bundle update 來更新 gems 以確保版本匹配)

問題是您只更改了Gemfile的 Ruby 版本號,而沒有重新創建有效的Gemfile.lock 這導致Gemfile.lock包含與 Ruby 2.2.4 不兼容的版本中的 Gems。

如果您更改了Gemfile中的Gemfile那么您必須在推送到 Heroku 之前使用相同的 Ruby 版本更新或重新創建Gemfile.lock

我建議使用 Ruby 版本管理器(如rbenvRVM )以便能夠在您的開發機器上運行多個版本的 Ruby。 然后通過更改Gemfile (對於 Heroku)和.ruby-version (對於您的本地環境)中的 Ruby 版本來更新您的應用程序中的 Ruby 版本。 兩個版本必須匹配。

完成后,運行bundle install以更新Gemfile.lock或(當有重大更新或您只想確保使用最新版本時)運行bundle update以重新創建Gemfile.lock

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM