Gem::Loaderror: Specified 'Sqlite3' for Database Adapter, But the Gem Is Not Loaded

Specified sqlite3 for database adapter but gem is not loaded

Your sqlite3 gem is not being loaded, because of where you've got it in the Gemfile. Take it out of platform :ruby do and place it outside of that block , May be right under gem 'rails', '~> 4.2.0'

Specified sqlite3 gem not loaded

It is very strange but two weeks ago I also got the same issue, and when I initiate my rails new project it put gem 'sqlite3' without any version number, and I get the same error. So I played a lot on brew so I thought it is an issue due to that playing with SQLite, somehow I came to know that maybe my Sqlite3 gem has an issue. And I noticed it is loading 1.4 version of it.

I did following change and it worked.

gem 'sqlite3', '~> 1.3.11'

Just in case if someone searching answer of this question, as it resolved issue of question asker.

Heroku build error: Specified 'sqlite3' for database adapter, but the gem is not loaded

SQLite does not work with Heroku as its disk based and Heroku uses an ephemeral file system.

SQLite runs in memory, and backs up its data store in files on disk.
While this strategy works well for development, Heroku’s Cedar stack
has an ephemeral filesystem. You can write to it, and you can read
from it, but the contents will be cleared periodically. If you were to
use SQLite on Heroku, you would lose your entire database at least
once every 24 hours.

Even if Heroku’s disks were persistent running SQLite would still not
be a good fit. Since SQLite does not run as a service, each dyno would
run a separate running copy. Each of these copies need their own disk
backed store. This would mean that each dyno powering your app would
have a different set of data since the disks are not synchronized.

-Heroku Devcenter: SQLite on Heroku

Heroku provides Postgres as the free default database for rails which is as close to a recommendation as you can get.

If you are deploying to Postgres you should also be developing/testing on Postgres.

Differences between backing services mean that tiny incompatibilities
crop up, causing code that worked and passed tests in development or
staging to fail in production. These types of errors create friction
that disincentivizes continuous deployment. The cost of this friction
and the subsequent dampening of continuous deployment is extremely
high when considered in aggregate over the lifetime of an application.

  • https://12factor.net/dev-prod-parity

If you really want to stick with SQLite you need to configure the adapters properly:

default: &default
adapter: sqlite3
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000

development:
<<: *default
database: db/development.sqlite3

test:
<<: *default
database: db/test.sqlite3

production:
<<: *default
adapter: postgresql
# nothing else is needed

I do not recommend this.

Having difficulties to add sqlite3 into gemfile

Got it working by updating gemfile.lock

Changed sqlite3 (1.4.0) to sqlite3 (1.3.13).

Update:
Don't forget to specify your gem version in gemfile.
Example: gem 'sqlite3', '~> 1.3.13', otherwise bundle update command will return an error.

Rails 5 and MongoDB: Specified 'sqlite3' for database adapter, but the gem is not loaded

Remove your generated application then generate a new rails application with --skip-active-record option.

rails new your-project --skip-active-record

Then add mongo adapter to your Gemfile and so on.

Gem::LoadError Specified 'mysql2' for database adapter, but the gem is not loaded

It doesn't load mysql2 gem because new version of mysql2(0.4.1) gem unable to load the mysql2_adaptor. This is working for me.

gem 'mysql2', '~> 0.3.13'

and run

bundle install

If still facing problem then This solution will surely help

Note: I'm assuming that you've mysql database installed on your system :P



Related Topics



Leave a reply



Submit