Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku: push rejected - failed to install gems via bundler

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
like image 327
Leahcim Avatar asked Jun 03 '12 00:06

Leahcim


3 Answers

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 
like image 178
Arel Avatar answered Nov 14 '22 23:11

Arel


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.

like image 35
Mike Cottier Avatar answered Nov 14 '22 23:11

Mike Cottier


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

like image 22
Shane O'Connor Avatar answered Nov 15 '22 00:11

Shane O'Connor