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.
Rails 4 - Heroku Sqlite3 error
I've had similar problems before. This works for me in my Gemfile:
gem 'sqlite3', group: [:development, :test]
gem 'pg', group: [:production]
Also, in your local git checkout, execute the command heroku config
. Confirm that the output has the following environment variables set:
RACK_ENV: production
RAILS_ENV: production
Give that a shot. Does it work for you?
Error loading the 'sqlite3' Active Record adapter. when I deploy in Heroku
You should remove SQLite from your application and use Postgres in development, testing and production. There are many small incompatibilities between RDBMS's and you don't want to discover them when you push your app to production.
1. Install Postgres on the local system.
How to do this depends on your system. OS-X and Windows have simple installers. On Linux you would install it through your package manager.
2. Remove the sqlite gem.
# remove
gem 'sqlite3', '~> 1.3.6'
# add
gem 'pg', '~> 0.18.4' # check rubygems.org for the latest version
Run bundle update
to regenerate the Bundle.lock
.
3. Configure database.yml
default: &default
adapter: postgresql
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
development:
<<: *default
database: 'my_app_development'
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: 'my_app_test'
# On Heroku you don't need the production section as it provides everything through
# ENV["DATABASE_URL"]
# Heroku sets pretty good defaults as well so YAGNI.
4. Commit and push
Heroku Push error Detected sqlite3 gem which is not supported on Heroku.
Heroku ignores development gems; however, you've misspelled development, thus Heroku attempts to install the gem.
group :devlopment, :test do
gem 'sqlite3'
end
Change it to :development
Can't push rails app to heroku because of sqlite3?
This is because herouku uses your gemfile.lock to know the gems and versions to use instead of the gemfile, you must:
- run a bundle install locally to update your gemfile.lock
- commit and push that change to git(hub)
- push to heroku.
Good luck!
Edit: Also, make sure to include your gemfile.lock to git, although that's kind of obvious
Rails Heroku sqlite error
I was trying to push to Herkou from a local branch of mine. Turns out by default it pushes the master branch (which made use of the sqlite gem).
I was able to successfully push my local branch by doing:
git push heroku (branchname):master
source: https://devcenter.heroku.com/articles/multiple-environments#advanced-linking-local-branches-to-remote-apps
Related Topics
Shading Mask Algorithm for Radiation Calculations
Uri::Invalidurierror: Bad Uri(Is Not Uri) Testing Rails Controllers
Ruby: Difference Between Read_Timeout and Open_Timeout
Regex Negative Lookbehind in Ruby Doesn't Seem to Work
Openssl Causing Very Slow Rails Boot Time on Windows
Error: Null Value in Column "Id" Violates Not-Null Constraint
Adapters Not Working with Datamapper
Increase Timeout for Net::Http
How to Install Ruby System-Wide Using Rbenv
Should Repeat a Number of Times
What Does "File.Sync = True" Do
Assign to an Array and Replace Emerged Nil Values
Conditional Dependency in Ruby Gemspec