【问题标题】:Why does my heroku app depend on will_paginate gem, which is not in my gemfile anymore?为什么我的 heroku 应用程序依赖 will_paginate gem,它不再在我的 gemfile 中?
【发布时间】:2013-12-09 09:07:34
【问题描述】:

为什么我的 heroku 应用程序依赖 will_paginate gem,而这已经不在我的 gemfile 中了?

你好,

我有一个在 Heroku 上运行的 rails 3.2.11 应用程序。自从我上次成功部署到 Heroku 以来,我在本地:

  • 卸载 will_paginate gem 并更新 Gemfile
  • 将 kaminari 宝石添加到 Gemfile 中
  • 将 will_paginate 调用替换为 kaminari 调用
  • 其他一些变化...

此应用程序在本地运行良好。

当我将此应用程序(从 gi​​t)部署到 heroku 时,日志中出现以下异常:

» 12:47:45.667 2013-12-07 11:47:45.613491+00:00 heroku web.1 - - Starting process with command `bundle exec rails server thin -p 31620 -e $RACK_ENV`
» 12:47:48.465 2013-12-07 11:47:48.410856+00:00 app web.1 - - => Booting Thin
» 12:47:48.564 2013-12-07 11:47:48.410856+00:00 app web.1 - - => Rails 3.2.11 application starting in production on http://0.0.0.0:31620
» 12:47:48.564 2013-12-07 11:47:48.410856+00:00 app web.1 - - => Call with -d to detach
» 12:47:48.564 2013-12-07 11:47:48.410856+00:00 app web.1 - - => Ctrl-C to shutdown server
» 12:47:48.564 2013-12-07 11:47:48.410856+00:00 app web.1 - - Connecting to database specified by DATABASE_URL
» 12:47:48.922 2013-12-07 11:47:48.860489+00:00 app web.1 - - Exiting
» 12:47:48.922 2013-12-07 11:47:48.861515+00:00 app web.1 - - /app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:317:in `rescue in depend_on': No such file to load -- will_paginate (LoadError) from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:312:in `depend_on' from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:225:in `require_dependency' from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/engine.rb:439:in `block (2 levels) in eager_load!' from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/engine.rb:438:in `each' from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/engine.rb:438:in `block in eager_load!' from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/engine.rb:436:in `each' from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/engine.rb:436:in `eager_load!' from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/application/finisher.rb:53:in `block in <module:Finisher>' from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `instance_exec' from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `run' from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/initializable.rb:55:in `block in run_initializers' from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `each' from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `run_initializers' from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/application.rb:136:in `initialize!' from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in `method_missing' from /app/config/environment.rb:41:in `<top (required)>' from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require' from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `block in require' from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency' from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require' from /app/config.ru:3:in `block in <main>' from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval' from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize' from /app/config.ru:in `new' from /app/config.ru:in `<main>' from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval' from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file' from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:200:in `app' from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/commands/server.rb:46:in `app' from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app' from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:254:in `start' from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/commands/server.rb:70:in `start' from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/commands.rb:55:in `block in <top (required)>' from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/commands.rb:50:in `tap' from /app/vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/commands.rb:50:in `<top (required)>' from script/rails:6:in `require' from script/rails:6:in `<main>' EXCEPT
» 12:47:50.130 2013-12-07 11:47:50.075742+00:00 heroku web.1 - - Process exited with status 1
» 12:47:51.142 2013-12-07 11:47:50.088491+00:00 heroku web.1 - - State changed from starting to crashed
» 12:47:53.004 2013-12-07 11:47:42.195734+00:00 heroku web.1 - - State changed from crashed to starting

看来我在 Heroku 上的应用仍然需要 will_paginate gem。我怎样才能找出原因?

我尝试将这个应用部署到一个新的 heroku 应用,它基本上应该只从我的 Git 中获取代码,而不是引用一些以前部署的代码/配置,但结果是一样的。

这是我的 Gemfile:

source 'https://rubygems.org'

gem 'rails', '3.2.11'

# REPLACED BY KAMINARI gem: gem 'will_paginate' #, "~> 2.3.11", :source => 'http://gemcutter.org'
gem 'kaminari'

gem 'meta_search', "~> 1.1.3"
gem 'hirb', "0.5.0"
gem "paperclip", "~> 3.0"
gem 'i18n'
gem 'rake', '10.0.3'

# needed for amazon s3
gem 'aws-sdk'

# needed for mysql (cleardb mysql on heroku)
gem 'activerecord-mysql-adapter'
gem 'mysql2'

group :development, :test do

end

group :production do
    gem 'pg'

    # for heroku production
    gem 'thin'  

    gem 'rails_12factor'

end

# Gems used only for assets and not required
# in production environments by default.
group :assets do

    # to be able to test thin locally
    gem 'foreman'

    gem "hirb", "0.5.0"

    gem 'factory_girl'

    gem 'sass-rails',   '~> 3.2.3'
    gem 'coffee-rails', '~> 3.2.1'

    # See https://github.com/sstephenson/execjs#readme for more supported runtimes
    # gem 'therubyracer', :platforms => :ruby

    gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'debugger'

【问题讨论】:

  • 您是否在控制台中尝试过heroku run bundle update?这将在 Heroku 上运行 bundler,这可以解决它吗?
  • 是的,但没有帮助。

标签: ruby-on-rails heroku


【解决方案1】:

/config/initializers/ 中有一个引用 will_paginate 的剩余初始化程序。

【讨论】:

  • 您好,我查看了本地的config/initializers目录,但没有发现对will_paginate的引用。你知道我是否可以在 heroku 上检查我的应用程序中是否还有这样的初始化程序?谢谢
  • 您是否在将更改推送到 Heroku 之前提交了更改?该错误肯定是引用了一个初始化程序。
  • 是的,最新的改动已经推送到github了。这些更改已部署到 heroku。有没有办法检查 heroku 上的初始化程序目录的内容?
  • 你是对的:仍然有一个文件引用将分页:app/helpers/remote_link_renderer.rb 奇怪的是,这并没有在我没有安装 will_paginate 的开发环境中引起问题,这意味着该文件仅在生产期间加载?反正已经修好了,谢谢!
  • 开发会自动加载——它只在需要时加载文件。如果您没有访问该文件中的方法,它们将永远不会被加载并且永远不会出错。生产在服务器启动时加载所有内容并将其保存在内存中以提高速度,这可能是它仅在此处触发的原因。
猜你喜欢
  • 1970-01-01
  • 2014-01-02
  • 2011-11-18
  • 2019-03-03
  • 1970-01-01
  • 1970-01-01
  • 2012-08-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多