[英]Heroku doesn't see gem 'pg'
Need help. 需要帮忙。
When I try to make user@X220:~/rails_projects/sample_app$ heroku run rake db:migrate
当我尝试使user@X220:~/rails_projects/sample_app$ heroku run rake db:migrate
There is a mistake: 有一个错误:
Running rake db:migrate on limitless-fjord-69900.... up, run.2816 rake aborted! 在ranchless-fjord-69900上运行rake db:migrate ....起来,运行2816 rake已中止!
Gem::LoadError: Specified 'postgresql' for database adapter, but the gem is not loaded. Gem :: LoadError:为数据库适配器指定了“ postgresql”,但未加载gem。
Addgem 'pg'
to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). 将gem'pggem 'pg'
添加到您的Gemfile中(并确保其版本为ActiveRecord要求的最低版本)。
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/connection_specification.rb:177:inrescue in spec' /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/connection_specification.rb:174:in
spec' /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_handling.rb:50:inestablish_connection' /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/railtie.rb:120:in
block (2 levels) in ' /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:38:ininstance_eval' /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:38:in
execute_hook' /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:45:inblock in run_load_hooks' /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:44:in
each' /app/vendor/bundle/ruby/2.2.0/gem /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/connection_specification.rb:177:rescue in spec' /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/connection_specification.rb:174:in
spec'/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_handling .rb:50:在establish_connection' /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/railtie.rb:120:in
:在/ app /中的块(2个级别) vendor / bundle / ruby / 2.2.0 / gems / activesupport-4.2.6 / lib / active_support / lazy_load_hooks.rb:38:ininstance_eval' /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:38:in
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-instance_eval' /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:38:in
execute_hook中/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:45instance_eval' /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:38:in
run_load_hooks中的block in run_load_hooks' /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:44:in
每个中/app/vendor/bundle/ruby/2.2.0/gem s/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:44:inrun_load_hooks' /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/base.rb:315:in
' /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/base.rb:26:in<top (required)>' /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/tasks/mysql_database_tasks.rb:8:in
' . s / activesupport-4.2.6 / lib / active_support / lazy_load_hooks.rb:44:在run_load_hooks' /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/base.rb:315:in
'/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/base.rb:26run_load_hooks' /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/base.rb:315:in
<top (required)>' /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/tasks/mysql_database_tasks.rb:8:in
'。 . 。 . 。
Tasks: TOP => db:migrate => db:load_config (See full trace by running task with --trace) 任务:TOP => db:migrate => db:load_config(通过使用--trace运行任务来查看完整跟踪)
My Gemfile is: 我的Gemfile是:
'source 'https://rubygems.org'
ruby '2.2.0'
gem 'activerecord', '~> 4.2', '>= 4.2.6'
gem 'rails', '4.2.6'
group :development, :test do
gem 'byebug'
gem 'sqlite3', '~> 1.3', '>= 1.3.11'
gem 'rspec-rails', '~> 2.8'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
end
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'therubyracer', platforms: :ruby
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
group :doc do
gem 'sdoc', '~> 0.4.0', require: false
end
gem 'unicorn'
group :development do
gem 'web-console', '~> 2.0'
gem 'spring'
end
group :production do
gem 'rails_12factor'
gem 'pg'
end
What's wrong? 怎么了?
Remove or comment gem 'sqlite3'
from your Gemfile
even if it in development
group. 从Gemfile
删除或注释Gemfile
gem 'sqlite3'
,即使它在development
组中也是如此。 I don't know why but Heroku doesn't run your application when it contains sqlite
gem outside production. 我不知道为什么,但是当Heroku在生产之外包含sqlite
gem时,它不会运行您的应用程序。
If you are use SQLite in development, you have to comment gem 'sqlite'
every time when deploying to Heroku and uncomment after deploying. 如果您在开发中使用SQLite,则每次部署到Heroku时都必须注释gem 'sqlite'
,并在部署后取消注释。
Better way will be use Postgres in development. 更好的方法是在开发中使用Postgres。
As suggested before, this could have to do with your sqlite
gem. 如前所述,这可能与您的sqlite
宝石有关。
If you still want to use sqlite
you can set to ignore that group. 如果仍要使用sqlite
,则可以设置为忽略该组。 From Heroku docs: 来自Heroku的文档:
To specify groups of gems to not to be installed, you can use the
BUNDLE_WITHOUT
config var. 要指定不要安装的gem组,可以使用BUNDLE_WITHOUT
配置BUNDLE_WITHOUT
。
$ heroku config:set BUNDLE_WITHOUT="development:test"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.