曾濟彬
曾濟彬

Reputation: 21

Gem::LoadError: Error loading the 'sqlite3' Active Record adapter

I am doing heroku run rake db:migrate and this is the error:

Gem::LoadError: Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? sqlite3 is not part of the bundle. Add it to your Gemfile.

Gemfile:

group :production do
  gem 'pg', '~> 0.18'
end

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  # Use sqlite3 as the database for Active Record
  gem 'sqlite3'
end

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

group :test do
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 2.15'
  gem 'selenium-webdriver'
  # Easy installation and use of chromedriver to run system tests with Chrome
  gem 'chromedriver-helper'
end

Database.yml

production:
  adapter: postgresql
  encoding: Unicode    

Upvotes: 2

Views: 11731

Answers (3)

I had the same problem, I solved it downgrading the version that rails new installs by default.

remove the current version of the sqlite3 gem with 'gem uninstall sqlite3' then modify the GemFile to include the sqlite3 version. I my case I set the version '~1.3.6' and that soled the problem

Upvotes: 3

JamesSchiiller
JamesSchiiller

Reputation: 83

If you are trying to use use a different database other than sqlite,

  1. remove sqlite3 in gemfile and bundle install

  2. remove sqlite3 in database.yml

  3. rake db:create <---------------- or will complain no db error in browser

Upvotes: 1

ainza
ainza

Reputation: 36

Rails 5 & below you need to 'rails_12factor'gem.... Rails 5 & above this is not required.

Also noticed you don't have sqlite3 in your development environment, it may not matter but just place it there for good measure.

Upvotes: 0

Related Questions