avzah
avzah

Reputation: 23

Heroku doesn't see gem 'pg'

Need help.

When I try to make 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!
Gem::LoadError: Specified 'postgresql' for database adapter, but the gem is not loaded.
Add gem 'pg' to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/connection_specification.rb:177:in rescue in spec' /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/connection_specification.rb:174:inspec' /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_handling.rb:50:in establish_connection' /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/railtie.rb:120:inblock (2 levels) in ' /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:38:in instance_eval' /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:38:inexecute_hook' /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:45:in 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:ineach' /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:44:in 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: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' . . .
Tasks: TOP => db:migrate => db:load_config (See full trace by running task with --trace)

My Gemfile is:

'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?

Upvotes: 2

Views: 1063

Answers (2)

dan-klasson
dan-klasson

Reputation: 14230

As suggested before, this could have to do with your sqlite gem.

If you still want to use sqlite you can set to ignore that group. From Heroku docs:

To specify groups of gems to not to be installed, you can use the BUNDLE_WITHOUT config var.

$ heroku config:set BUNDLE_WITHOUT="development:test"

Upvotes: 1

General Failure
General Failure

Reputation: 2597

Remove or comment gem 'sqlite3' from your Gemfile even if it in development group. I don't know why but Heroku doesn't run your application when it contains sqlite gem outside production.

If you are use SQLite in development, you have to comment gem 'sqlite' every time when deploying to Heroku and uncomment after deploying.
Better way will be use Postgres in development.

Upvotes: 2

Related Questions