6

I've tried to push an app to Heroku in the same way I have always done. I'm using Ruby 1.9.2 and Rails 3.2.1. However, now I'm getting this error message. I did what it recommends

make sure that `gem install sqlite3 -v '1.3.5'` succeeds before bundling.

Note, it's doing this even though I did in my gemfile

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

but doing gem install sqlite3 -v '1.3.5' in the terminal, but the push is still being rejected. I'm not sure how to check the Gem files it refers to in the tmp directory but even if I did, i wouldn't understand them

Any suggestions?

Gem files will remain installed in /tmp/build_1timyd7o5k59l/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.5 for inspection.
       Results logged to /tmp/build_1timyd7o5k59l/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.5/ext/sqlite3/gem_make.out
       An error occurred while installing sqlite3 (1.3.5), and Bundler cannot continue.
       Make sure that `gem install sqlite3 -v '1.3.5'` succeeds before bundling.
 !
 !     Failed to install gems via Bundler.
 !
 !     Heroku push rejected, failed to compile Ruby/rails app
Leahcim
  • 40,649
  • 59
  • 195
  • 334

4 Answers4

9

I always just comment out the SQLite3 gem and it works well for me, so when I push to heroku my gemfile looks like this:

# Development Database
#gem 'sqlite3'
# Production Database
gem 'pg'

EDIT:

The above solution works, and is easy if you don't want to update your gems for whatever reason. The better long term solution to this problem is to do the following:

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

then delete your gemfile.lock file. You'll need to generate a new gemfile.lock file that reflects your changes. In the terminal run:

bundle update

Finally, update your repository and push to heroku by doing the following in the terminal:

git add .
git commit -m "commit message"
git push heroku 
Arel
  • 3,888
  • 6
  • 37
  • 91
  • 1
    Great and simple answer! Thank you! – RileyE Oct 30 '12 at 15:45
  • You should use the same SQL engine both in production and development, as there might be some technical differences, introducing bugs in production which you could not see nor reproduce in development. – Damien MATHIEU Jun 14 '13 at 19:14
  • That's true, but the question was how to do the above. The above is fine for simple sites, or beginners who want to use SQLite locally. – Arel Jun 28 '13 at 15:16
2

Actually your initial Gemfile code was correct if you wanted to use sqlite3 locally. like you showed, you put this in the gem file:

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

then you have to delete your local Gemfile.lock, and run:

bundle update

to re-build the .lock file. then add and re-commit the Gemfile:

git add Gemfile
git commit -m "Gemfile commit message"

then push the new Gemfile to the repo:

git push master

change the GIT details accordingly of course, but you get the point. it's all about adding/committing/pushing the Gemfile.

Mike Cottier
  • 109
  • 2
  • 1
1

As far as I know Heroku does not support sqlite3, but instead you with a PostgreSQL database. You'll need to modify your Gemfile as such, and your database.yml. So for your production group, in your Gemfile, you'll want:

https://devcenter.heroku.com/articles/rails3

edit:

There appears to be a more detailed answer here, so this may be a duplicate: Pushing Rails with SQLite3 to Heroku fails

Community
  • 1
  • 1
Shane O'Connor
  • 704
  • 6
  • 14
1

you must add updated Gemfile.lock to git and try git push heroku master... it worked for me and for sure it will for you too

and donot forget to add config.action_controller.perform_caching = true