Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying RoR app to Heroku with SQLite 3 fails

I'm trying to deploy my first app to Heroku. I'm using SQLite as the database. As far as I know Heroku doesn't use SQLite - it switches to Postgres in the backend.

When I'm deploying I get the following error:

/usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:64:in `require': no such file to load -- sqlite3 (LoadError)

My Gemfile (which is what I assume is causing this problem) looks as follows:

source 'http://rubygems.org'  gem 'rails', '3.0.0'         gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3' 

What am I doing wrong?

like image 205
Jaco Pretorius Avatar asked Oct 09 '10 18:10

Jaco Pretorius


People also ask

Why can we not use SQLite when uploading to Heroku?

Disk backed storage 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.

Can we deploy sqlite3 on Heroku?

However, it seems to be that Heroku doesn't support applications with sqlite3 as the database.


1 Answers

Heroku doesn't support SQLite databases. You need to use PostgreSQL on production, as I also explained in this post.

group :production do   gem "pg" end  group :development, :test do   gem "sqlite3", "~> 1.3.0" end 

Actually, it's recommended to use in development/test an environment as close as possible to production. Therefore, I suggest you to switch all your environments to PostgreSQL.

# replace gem "sqlite3" with gem "pg" 
like image 188
Simone Carletti Avatar answered Sep 30 '22 18:09

Simone Carletti