4

I'm building a small app and it was working locally. Then when I went to deploy it on Heroku, this error popped up in my terminal:

remote:        An error occurred while installing sqlite3 (1.3.11), and 

Bundler cannot
remote:        continue.
remote:        Make sure that `gem install sqlite3 -v '1.3.11'` succeeds before bundling.
remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !     
remote:  !     Detected sqlite3 gem which is not supported on Heroku.
remote:  !     https://devcenter.heroku.com/articles/sqlite3
remote:  !
remote: 
remote:  !     Push rejected, failed to compile Ruby app
remote: 
remote: Verifying deploy...
remote: 
remote: !   Push rejected to pockettheskimm.
remote: 
To https://git.heroku.com/pockettheskimm.git
 ! [remote rejected] master -> master (pre-receive hook declined)

I subsequently read the documentation on Heroku, which told me that I have to use Postgres in my app instead of sqlite3. So I updated my app, swapping out sqlite3 for Postgres:

default: &default
  adapter: postgresql
  pool: 5
  timeout: 5000

development:
  <<: *default
  database: db/development.postgresql

# 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:
  <<: *default
  database: db/test.postgresql

production:
  <<: *default
  database: db/production.postgresql

but now when I run the app locally, I get this error in my browser:

ActiveRecord::NoDatabaseError
FATAL: database "db/development.postgresql" does not exist

Extracted source (around line #661):
659
660
661
662
663
664

        rescue ::PG::Error => error
          if error.message.include?("does not exist")
            raise ActiveRecord::NoDatabaseError.new(error.message, error)
          else
            raise
          end

What can I do to fix this?

3
  • 1
    You should read documentation carefully devcenter.heroku.com/articles/sqlite3#running-rails-on-postgres db/development.postgresql syntax is not allowed by postgres Commented Dec 10, 2015 at 13:58
  • 4
    Have you ran rake db:create && rake db:migrate on development after you've change your database.yml config file? Commented Dec 10, 2015 at 14:00
  • This is what the issue, was- thanks! Commented Dec 10, 2015 at 14:09

5 Answers 5

12

This was the answer that worked for me:

"Have you ran rake db:create && rake db:migrate on development after you've change your database.yml config file? "

credit to https://stackoverflow.com/users/163640/eugen

Sign up to request clarification or add additional context in comments.

Comments

1

This works for me:

rails db:create
rails db:migrate

Comments

0

Find the gem that has sqlite3 as a dependency and remove it from your Gemfile.Once you’ve done this run bundle install and ensure that sqlite3 no longer exists in your Gemfile.lock

Comments

0

try not using anything in your gem file until everything has proccesed otherwise ActiveRecord will function differently

Comments

-1

Some initialiser should be using the DB before it is created, so the db:create breaks.

To fix the error in the root cause, fix the initialisers and your lib settings.

ps: In my case, it was the FactoryBot.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.