RajeshM
RajeshM

Reputation: 872

SQLite used in production mode even if postgres is specified

My Rails app works fine in development mode. I then switch to production mode by doing bundle install --without development test. When I try to run rake (rake routes) I get this error: "

rake aborted! Gem::LoadError: Specified 'sqlite3' for database adapter, but the gem is not loaded. Add gem 'sqlite3' to your Gemfile

My Gemfile has:

group :development, :test do
  gem 'sqlite3', '1.3.10'
end
group :production do
  gem 'pg', '0.18.3'
  gem 'rails_12factor'
end

My config/database.yml looks like:

default: &default
  pool: 5
  timeout: 5000

development:
  <<: *default
  adapter: sqlite3
  database: db/development.sqlite3

test:
  <<: *default
  adapter: sqlite3
  database: db/test.sqlite3

production:
  <<: *default
  adapter: postgresql
  database: prod
  username: produser

My Gemfile.lock after bundle install --without production test has

GEM
  remote: https://rubygems.org/
  specs:
     ...
    pg (0.18.3)
    ...
    rails_12factor (0.0.3)
    ...
    sqlite3 (1.3.10)
    ...

DEPENDENCIES
  ...
  pg (= 0.18.3)
  ...
  rails_12factor (0.0.3)
  ...
  sqlite3 (= 1.3.10)
  ...

BUNDLED WITH
  1.10.6

I have updated to the Ruby 2.2.3, Rails 4.2.4, done gem update system and bundle update all to no avail.

Another question I have is why should the sqlite3 gem show up in my Gemfile.lock in production mode? Similarly, why does the pg gem show up in development mode?

Any help is appreciated.

Upvotes: 2

Views: 184

Answers (1)

ReggieB
ReggieB

Reputation: 8222

rake routes uses the default environment - which is development.

You need to either:

rake routes RAILS_ENV=production

or set the RAILS_ENV environment variable to 'production'

Upvotes: 3

Related Questions