[英]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 版本管理器(如rbenv或RVM )以便能够在您的开发机器上运行多个版本的 Ruby。 然后通过更改Gemfile
(对于 Heroku)和.ruby-version
(对于您的本地环境)中的 Ruby 版本来更新您的应用程序中的 Ruby 版本。 两个版本必须匹配。
完成后,运行bundle install
以更新Gemfile.lock
或(当有重大更新或您只想确保使用最新版本时)运行bundle update
以重新创建Gemfile.lock
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.