views:

133

answers:

3

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?

+2  A: 

Heroku doesn't support SQLite databases. You need to use PostgreSQL on production.

group :production, :staging do
  gem "pg"
end

group :development, :test do
  gem "sqlite3-ruby", "~> 1.3.0", :require => "sqlite3"
end
Simone Carletti
Are you sure? I'm following along in RailsTutorial.org - the author deploys to Heroku without changing anything
Jaco Pretorius
Read here http://docs.heroku.com/database
Simone Carletti
Thanks, I have no idea why the stupid tutorial doesn't mention that
Jaco Pretorius
Jaco/Simone, Heroku doesn't require that you reference PostgreSQL in your Gemfile however, and will ignore references to anything else in your database.yml file. I have an DB-based app running there with no specific reference to PG and it works just fine. That's why the book doesn't mention it.
Joost Schuur
A: 

I'm using sqlite3 and deploy to Heroku no problem. Here is my database.yml

SQLite version 3.x

gem install sqlite3-ruby (not necessary on OS X Leopard)

development: adapter: sqlite3 database: db/development.sqlite3 pool: 5 timeout: 5000

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: adapter: sqlite3 database: db/test.sqlite3 pool: 5 timeout: 5000

production: adapter: sqlite3 database: db/production.sqlite3 pool: 5 timeout: 5000

The database.yml file doesn't matter - "To ease deployment of typical Rails applications, Heroku automatically generates a new database.yml file on deployment"
Jaco Pretorius
A: 

Simone Carletti is correct and so is Joost. You only need to group the sqlite3 gem or remove it entirely from your Gemfile. Heroku just needs to know that you don't want to use sqlite3 for production

So this:

...
group :development, :test do
  gem "sqlite3-ruby", "~> 1.3.0", :require => "sqlite3"
end
...

Or this:

...
#No reference to sqlite3-ruby
...

If you remove the reference entirely you will probably mess up your local db though

hoitomt