2015-11-17 37 views
2

我以前在Heroku中部署過很少的問題。今天,我創建了一個非常基本的應用程序(字面上只是一個更新的gemfile的默認「新」),並將其推向Heroku。Heroku無法識別'spring'寶石,儘管它在Gemfile中列出

但是,Heroku並不認識'spring'寶石,即使它被列在Gemfile中。這導致我的應用程序崩潰。並且在被問及之前,是的,我在更新Gemfile後運行了bundle installbundle update

的Gemfile(從字面上回報率教程複製粘貼):

運行 heroku run rails console
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 

錯誤消息:

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的日誌:

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 [email protected] 
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 

任何幫助將是很大的不勝感激!

+0

會有幫助,如果你從heroku發佈日誌。 – Emanuel

+0

siaw23 - 我不確定是否應該,代碼H10上沒有太多文檔。但是,他們現在在那裏。 –

+0

您是否在部署到Heroku之前提交對Gemfile和Gemfile.lock所做的更改? – mmichael

回答

2

您在development組中擁有寶石。如果你把它從這個小組中拿出來放在主組中,那麼做另一個bundle install,把它加到回購中並重新部署,我認爲它會一切正常。

+0

這有效,但會引發更多問題。我製作的每個應用程序都是從RoR教程中複製/粘貼Gemfile開始的。直到現在,它每次都有效。 但是,這解決了我的問題。謝謝! –

+2

這是不好建議。你不想在生產中運行Spring。 – stef

0

最新版本的spring是1.4.2。你可能想要做那個版本,而不是舊版本。

+0

我在1.4.4上,仍然看到這個問題 - 請參閱我的答案,瞭解有關臨時補丁的說明。 – stef

1

我是Rails的新手,也經歷了教程。我有這個相同的問題。在經歷了與經驗豐富的Rails開發人員的多次討論和討論後,以下是答案。

看在bin /導軌根據你的日誌文件中第4行的文件:(這裏是代碼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行,然後錯誤將不會被提升,並且彈簧不會被加載。這是以前版本的bin/rails代碼所做的,並且一切正常。我不知道它是Rails還是Cloud9,或者生成這些代碼的東西,但最近幾天發生了一些變化,毫無疑問。

注意:一定要將spring gem留在gemfile的開發組中。我不會把春天的寶石移動到gem文件的主要組中,因爲不管我有限的知識如何,Spring都不應該在生產中運行。

希望這會有所幫助。

+0

評論此行適合我。感謝您的建議! – Sia

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根據他們的文件。

+1

謝謝@stef這工作像一個魅力。 –

相關問題