Heroku不认识春天'宝石,即使它在Gemfile中列出

时间:2015-11-17 02:10:45

标签: ruby-on-rails spring heroku

过去,我已经部署到Heroku,但问题很少。今天我创建了一个非常基本的应用程序(字面上只是默认的' new'带有更新的gemfile)并将其推送到Heroku。

然而,Heroku并没有认识到这个春天'宝石,即使它在Gemfile中列出。它导致我的应用程序崩溃。在它被问到之前,是的,我在更新Gemfile后运行了bundle installbundle update

Gemfile(从RoR教程中直接复制粘贴):

source 'https://rubygems.org'

gem 'rails',        '4.2.2'
gem 'sass-rails',   '5.0.2'
gem 'uglifier',     '2.5.3'
gem 'coffee-rails', '4.1.0'
gem 'jquery-rails', '4.0.3'
gem 'turbolinks',   '2.3.0'
gem 'jbuilder',     '2.2.3'
gem 'sdoc',         '0.4.0', group: :doc

group :development, :test do
  gem 'sqlite3',     '1.3.9'
  gem 'byebug',      '3.4.0'
  gem 'web-console', '2.0.0.beta3'
  gem 'spring',      '1.1.3'
end

group :test do
  gem 'minitest-reporters', '1.0.5'
  gem 'mini_backtrace',     '0.1.3'
  gem 'guard-minitest',     '2.3.1'
end

group :production do
  gem 'pg',             '0.17.1'
  gem 'rails_12factor', '0.0.2'
end

运行heroku run rails console后的错误消息:

Running rails console on pure-falls-2221... up, run.6936
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'spring' (= 1.1.3) among 59 total gem(s) (Gem::LoadError)
    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
    from /app/bin/spring:12:in `<top (required)>'
    from /app/bin/rails:4:in `load'
    from /app/bin/rails:4:in `<main>'

Heroku Logs:

2015-11-17T02:00:32.426615+00:00 heroku[slug-compiler]: Slug compilation started
2015-11-17T02:00:32.426624+00:00 heroku[slug-compiler]: Slug compilation finished
2015-11-17T02:00:35.179885+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 29889 -e production`
2015-11-17T02:00:37.945522+00:00 app[web.1]:    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
2015-11-17T02:00:37.945526+00:00 app[web.1]:    from bin/rails:4:in `<main>'
2015-11-17T02:00:37.945524+00:00 app[web.1]:    from /app/bin/spring:12:in `<top (required)>'
2015-11-17T02:00:37.945525+00:00 app[web.1]:    from bin/rails:4:in `load'
2015-11-17T02:00:37.945523+00:00 app[web.1]:    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
2015-11-17T02:00:37.945512+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'spring' (= 1.1.3) among 59 total gem(s) (Gem::LoadError)
2015-11-17T02:00:38.782080+00:00 heroku[web.1]: Process exited with status 1
2015-11-17T02:00:40.980407+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 7751 -e production`
2015-11-17T02:00:38.801178+00:00 heroku[web.1]: State changed from starting to crashed
2015-11-17T02:00:38.801178+00:00 heroku[web.1]: State changed from crashed to starting
2015-11-17T02:00:43.123615+00:00 app[web.1]: /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'spring' (= 1.1.3) among 59 total gem(s) (Gem::LoadError)
2015-11-17T02:00:43.123626+00:00 app[web.1]:    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
2015-11-17T02:00:43.123629+00:00 app[web.1]:    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
2015-11-17T02:00:43.123630+00:00 app[web.1]:    from /app/bin/spring:12:in `<top (required)>'
2015-11-17T02:00:43.123630+00:00 app[web.1]:    from bin/rails:4:in `load'
2015-11-17T02:00:43.123631+00:00 app[web.1]:    from bin/rails:4:in `<main>'
2015-11-17T02:00:44.203452+00:00 heroku[web.1]: State changed from starting to crashed
2015-11-17T02:01:05.291898+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pure-falls-2221.herokuapp.com request_id=adc1ccb9-cd90-45fd-b179-ef680f936c2f fwd="125.140.58.57" dyno= connect= service= status=503 bytes=
2015-11-17T02:01:06.107852+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=pure-falls-2221.herokuapp.com request_id=a92abeed-9b09-4ff8-b535-bac178eb454b fwd="125.140.58.57" dyno= connect= service= status=503 bytes=
2015-11-17T02:01:19.376119+00:00 heroku[api]: Starting process with command `rails console` by chrabyrd@gmail.com
2015-11-17T02:01:21.779621+00:00 heroku[run.6936]: Awaiting client
2015-11-17T02:01:21.797009+00:00 heroku[run.6936]: Starting process with command `rails console`
2015-11-17T02:01:22.153107+00:00 heroku[run.6936]: State changed from starting to up
2015-11-17T02:01:24.185437+00:00 heroku[run.6936]: State changed from up to complete
2015-11-17T02:01:24.169704+00:00 heroku[run.6936]: Process exited with status 1

非常感谢任何帮助!

5 个答案:

答案 0 :(得分:2)

您拥有development群组中的宝石。如果您将其从该组中取出并将其放入主组中,请执行另一个bundle install,将其添加到存储库并重新部署,我认为它将全部正常工作。

答案 1 :(得分:1)

我是Rails的新手并且也在阅读教程。我有同样的问题。经过多次观察和与经验丰富的Rails开发人员讨论后,这是答案。

根据你的日志文件查看第4行的bin / rails文件:(这是代码。第4行是发生错误的地方。)

#!/usr/bin/env ruby
begin
  spring_bin_path = File.expand_path('../spring', __FILE__)
  load spring_bin_path
rescue LoadError => e
  raise unless e.message.end_with? spring_bin_path, 'spring/binstub'
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'

如果删除第6行,则不会引发错误,也不会加载spring。这是以前版本的bin / rails代码所做的,并且一切正常。我不知道它是Rails还是Cloud9,或者是什么产生了这段代码,但最近几天发生了变化,毫无疑问。

注意:确保将spring gem留在gemfile的开发组中。我不会将spring gem移动到gemfile中的主要组,因为不管我的知识有多少,Spring都不应该在生产中运行。

希望这有帮助。

答案 2 :(得分:1)

我和spring人一起买了一张票

https://github.com/rails/spring/issues/450

我怀疑这与spring gem版本1.4.4

有关

答案 3 :(得分:1)

在Spring团队提出更好的解决方案之前,我修补了bin/rails并设置了一个Heroku环境变量,以避免在生产中加载Spring:

heroku config:set DISABLE_SPRING=1

<强>仓/轨道:

#!/usr/bin/env ruby
unless ENV["DISABLE_SPRING"]
  begin
    spring_bin_path = File.expand_path('../spring', __FILE__)
    load spring_bin_path
  rescue LoadError => e
    raise unless e.message.end_with? spring_bin_path, 'spring/binstub'
  end
end
APP_PATH = File.expand_path('../../config/application',  __FILE__)
require_relative '../config/boot'
require 'rails/commands'
根据他们的文档,

DISABLE_SPRINGthe recommended environment variable

答案 4 :(得分:0)

最新版本的弹簧是1.4.2。您可能希望以该版本而不是旧版本执行spring。