【问题标题】:Trouble with Deployment of a Rails App to Heroku将 Rails 应用程序部署到 Heroku 时遇到问题
【发布时间】:2016-08-27 19:44:05
【问题描述】:

更具体地说,在 Heroku 上运行 rails 控制台时,我在提取 heroku 日志时遇到 H10 错误,“No such file to load — pry (LoadError)”。

Rails 应用程序在 localhost 上运行良好。我搜索了所有应用程序的文件以删除对“require 'pry'”的引用以及对“binding.pry”的任何调用。 pry-railspry-nav gem 不应该在 Heroku 的生产环境中运行。我已经重新运行bundle install,在本地和 Heroku 上重置了我的数据库,确保我的代码在这些调整后被推送,并在 Heroku 上重置了测功机。

什么给了?

heroku 日志

2016-05-02T21:45:04.892586+00:00 heroku[router]: at=error code=H10 
desc="App crashed" method=GET path="/" host=chess-workout-andrew-smith.herokuapp.com request_id=f05db461-e4ef-48e4-b920-6b5163fa0ea2 fwd="69.156.77.15" dyno= connect= service= status=503 bytes=

2016-05-02T21:45:05.175027+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=chess-workout-andrew-smith.herokuapp.com request_id=fdbd387c-63fa-49e7-8d2c-e94f36558356 fwd="69.156.77.15" dyno= connect= service= status=503 bytes=

heroku run rails c

/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.1/lib/active_support/values/time_zone.rb:282: warning: circular argument reference - now
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:229:in `require': No such file to load -- pry (LoadError)
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.1/lib/active_support/values/time_zone.rb:282: warning: circular argument reference - now
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:229:in `require': No such file to load -- pry (LoadError)
    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:229:in `block in require'
    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:214:in `load_dependency'
    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:229:in `require'
    from /app/app/controllers/pieces_controller.rb:1:in `<top (required)>'
    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:229:in `require'
    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:229:in `block in require'
    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:214:in `load_dependency'
    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:229:in `require'
    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:330:in `require_or_load'
    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:289:in `depend_on'
    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:207:in `require_dependency'
    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.1/lib/rails/engine.rb:465:in `block (2 levels) in eager_load!'
    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.1/lib/rails/engine.rb:464:in `each'
    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.1/lib/rails/engine.rb:464:in `block in eager_load!'
    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.1/lib/rails/engine.rb:462:in `each'
    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.1/lib/rails/engine.rb:462:in `eager_load!'
    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.1/lib/rails/engine.rb:347:in `eager_load!'
    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.1/lib/rails/application/finisher.rb:56:in `each'
    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.1/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.1/lib/rails/initializable.rb:30:in `instance_exec'
    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.1/lib/rails/initializable.rb:30:in `run'
    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.1/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'
    from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
    from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from'
    from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'
    from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:345:in `each'
    from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:345:in `call'
    from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
    from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
    from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'
    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.1/lib/rails/initializable.rb:54:in `run_initializers'
    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.1/lib/rails/application.rb:215:in `initialize!'
    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /app/config/environment.rb:5:in `<top (required)>'
    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:229:in `require'
    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:229:in `block in require'
    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:214:in `load_dependency'
    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:229:in `require'
    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.1/lib/rails/application.rb:189:in `require_environment!'
    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.0.1/lib/rails/commands.rb:61:in `<top (required)>'
    from /app/bin/rails:4:in `require'
    from /app/bin/rails:4:in `<main>'

宝石文件:

source 'https://rubygems.org'

gem 'simple_form'

gem 'rails', '4.0.1'

gem 'pg'

gem 'sass-rails', '~> 4.0.0'

gem 'uglifier', '>= 1.3.0'

gem 'coffee-rails', '~> 4.0.0'

gem 'rails_12factor', group: :production

gem 'jquery-rails'

gem 'turbolinks'

gem 'jbuilder', '~> 1.2'

gem 'pry-rails', :group => :development

gem 'pry-nav', :group => :development

gem 'awesome_print', :group => :development

group :development, :test do
gem 'rspec-rails', '~> 3.0'
end

group :doc do
  gem 'sdoc', require: false
end

gem 'bootstrap-sass', '~> 3.3.4.1'

gem 'sprockets', '<= 2.11.0'

gem "devise"

gem "factory_girl_rails", "~> 4.0"

database.yml

development:  
  adapter: postgresql  
  encoding: unicode  
  database: chess_workout_development  
  pool: 5  
  username: postgres  
  password: password  
  host: localhost  


test:  
  adapter: postgresql  
  encoding: unicode  
  database: chess_workout_test  
  pool: 5  
  username: postgres  
  password: password  
  host: localhost  

production:  
  adapter: postgresql  
  encoding: unicode  
  database: chess_workout_production  
  pool: 5  
  username: postgres  
  password: password  
  host: localhost  

【问题讨论】:

  • 错误回溯的其余部分可能包含更多信息。此外,与 ruby​​ 2.2.0 兼容的第一个版本 rails 4.0.x 是后来的很多版本
  • @FrederickCheung 我已经在上面包含了详细的错误回溯,但是当我查看它时没有任何意义。您认为将 Rails 4.0.1 与 Ruby 2.2.0 一起使用可能会导致部署到 Heroku 时出现问题?
  • 这绝对是导致循环参数引用的原因。看起来您可能在pieces_controller.rb(第1行)中提到了pry
  • @FrederickCheung 升级到 Rails 4.0.9 解决了这个问题。感谢您的帮助!

标签: ruby ruby-on-rails-4 heroku


【解决方案1】:

来自heroku run rails console的错误日志说没有pry。在Gemfile 中,pry 仅用于开发环境,尽管我很确定在控制器文件中设置了 require 'pry' 以使 heroku 感到困惑。

您可以在 Gemfile 中从 :group =&gt; :development 中删除 pry,不要忘记 heroku run bundle install

【讨论】:

    猜你喜欢
    • 2017-05-03
    • 2021-04-21
    • 1970-01-01
    • 2011-10-03
    • 2014-06-20
    • 1970-01-01
    • 2021-11-08
    • 2011-08-30
    • 1970-01-01
    相关资源
    最近更新 更多