Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pushing Rails with SQLite3 to Heroku fails [duplicate]

I experience the same scenario as described in Heroku deployment issue when I try to deploy my Rails 3 app to Heroku and sqlite3 is defined in the gems file.

/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)

Any clue why this is? The solution defined in the ruby-forum works, I just wondered why.

like image 265
John Korsnes Avatar asked Sep 19 '10 18:09

John Korsnes


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.


3 Answers

Make sure you don't include sqlite in your Gemfile in production environments:

This is right:

source :gemcutter
gem 'rails'

group :development, :test do
  gem 'sqlite3-ruby', :require => 'sqlite3'
end

This is wrong:

source :gemcutter
gem 'rails'        
gem 'sqlite3-ruby', :require => 'sqlite3'
like image 72
Johannes Brodwall Avatar answered Oct 14 '22 12:10

Johannes Brodwall


SQLite requires a permanent writable file system. (i.e. Your program ultimately needs access to the POSIX fopen() and fwrite() API calls to a particular file). Heroku does not provide a permanent writable file system. Therefore, SQLite 3 won't work.

like image 28
Jay Godse Avatar answered Oct 14 '22 10:10

Jay Godse


Because of theirs arhitecture, Heroku allows only postgres, so sqlite gem not installed.

like image 24
valodzka Avatar answered Oct 14 '22 12:10

valodzka