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.
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'
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.
Because of theirs arhitecture, Heroku allows only postgres, so sqlite gem not installed.
I thing sqlite3 is intentionally not provided at Heroku because this database system is embedded database which runs in same process as application. Heroku is distributed environment which means same application may run on many machines within many processes. That would give multiple separated sqlite3 instances - totally unrelated (imagine two isolated separate mysqls on two machines).
In distributed environment at least the 'client-server' centralized type database must be used, e.g: MySQL, PostgreSQL, Oracle.
For more recent versions of Sqlite, you may use this instead:
group :development, :test do
gem 'sqlite3'
end
This fixed it for me.