2016-05-01 132 views
2

我最近试图在Heroku上部署我的rails应用程序时遇到了麻烦。在过去,我已经在Heroku上部署了应用程序,没有问题,但Heroku不再支持Ruby 2.0.0。他们建议将ruby "2.2.4"添加到Gemfile,这正是我所做的。我Gemfile的开头如下:Heroku,bundler失败,失去依赖关系

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 
... 

所以,我在我的电脑上没有问题运行bundle install与1.7.8版本。我甚至可以在生产模式下运行我的应用程序。但是,当我尝试在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 

任何帮助都将不胜感激。

+0

我没有使用Heroku Git - 我正在通过DropBox –

+0

你是说我应该在命令行上运行'heroku config:set BUNDLE_WITHOUT =“development:test”'? –

回答

2

我建议删除您的Gemfile.lock,再次在本地运行bundle install,将新的Gemfile.lock提交到您的git存储库,然后再次尝试您的git push heroku master

+1

@orangeplus同样的交易。你应该尝试删除你的gemfile.lock。错误消息说它已经损坏,我想这是因为当它最初生成时,你使用的是Ruby 2.0.x,现在你已经指定了一个更新的版本。所以你需要用顶部的规范重新生成你的Gemfile.lock。不确定,但似乎可行。 –

+0

谢谢你的帮助。这对我有效。 –

+0

@orangeplus非常欢迎,我很高兴能够帮助。推到Heroku有时可能是个婊子。 :) –

0

我有同样的问题,我所做的就是我在我的系统更新2.2.4红宝石并重新启动终端,然后按照这些步骤:

bundle install 
bundle update 
git push heroku 

(它的更新与捆绑的宝石是个好主意更新以确保版本匹配)

0

问题是,您只更改了Gemfile中的Ruby版本号,但未重新创建有效的Gemfile.lock。这会导致一个Gemfile.lock,其中包含与Ruby 2.2.4不兼容的Gems版本。

如果您在Gemfile中更改了某些内容,则必须在推送到Heroku之前使用相同的Ruby版本更新或重新创建Gemfile.lock

我建议使用Ruby版本管理器(如rbenvRVM)能够在您的开发机器上运行多个版本的Ruby。然后通过更改Gemfile(适用于Heroku)和.ruby-version(适用于您的本地环境)中的Ruby版本来更新应用程序中的Ruby版本。两个版本都必须匹配。

一旦做到这一点,运行bundle install更新Gemfile.lock或(当有重大更新,或者你只是想确保你使用最新版本)运行bundle update重新创建Gemfile.lock