25

I'm following this tutorial, but it fails when I try to push to Heroku. It seems "sqlite3.h" is missing. I'm new to development so I'm not sure what information will help people diagnose the problem, so here's everything :). I'm running on Mac OS X 10.7 Lion. Here are the versions of everything I'm working with:

Amits-MacBook-Air-2:demo_app amitgupta$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.3.0]
Amits-MacBook-Air-2:demo_app amitgupta$ rails -v
Rails 3.2.3
Amits-MacBook-Air-2:demo_app amitgupta$ sqlite3 -version
3.7.11 2012-03-20 11:35:50 00bb9c9ce4f465e6ac321ced2a9d0062dc364669
Amits-MacBook-Air-2:demo_app amitgupta$ heroku -v
2.25.0
Amits-MacBook-Air-2:demo_app amitgupta$ port -v
MacPorts 2.0.4
Entering interactive mode... ("help" for help, "quit" to quit)
[RailsApps/demo_app] > quit 
Goodbye

When I try to push to Heroku:

Amits-MacBook-Air-2:demo_app amitgupta$ heroku create --stack cedar
Creating floating-stream-8009... done, stack is cedar
http://floating-stream-8009.herokuapp.com/ | [email protected]:floating-stream-8009.git
Amits-MacBook-Air-2:demo_app amitgupta$ git push heroku master

Here's what I get:

Counting objects: 119, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (104/104), done.
Writing objects: 100% (119/119), 33.74 KiB, done.
Total 119 (delta 17), reused 0 (delta 0)

-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.1.2
       Running: bundle install --without development:test --path vendor/bundle --binstubs bin/ --deployment
       Fetching gem metadata from https://rubygems.org/.......
       Installing rake (0.9.2.2)
       .
       .
       .
       Installing sqlite3 (1.3.6) with native extensions
       Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
       /usr/local/bin/ruby extconf.rb
       checking for sqlite3.h... no
       sqlite3.h is missing. Try 'port install sqlite3 +universal'
       or 'yum install sqlite-devel' and check your shared library search path (the
       location where your sqlite3 shared library is located).
       *** extconf.rb failed ***
       Could not create Makefile due to some reason, probably lack of
       necessary libraries and/or headers.  Check the mkmf.log file for more
       details.  You may need configuration options.
       Provided configuration options:
       --with-opt-dir
       .
       .
       .
       --disable-local
       Gem files will remain installed in /tmp/build_2l2dn7bx7lu34/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.6 for inspection.
       Results logged to /tmp/build_2l2dn7bx7lu34/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.6/ext/sqlite3/gem_make.out
       An error occured while installing sqlite3 (1.3.6), and Bundler cannot continue.
       Make sure that `gem install sqlite3 -v '1.3.6'` succeeds before bundling.
 !
 !     Failed to install gems via Bundler.
 !
 !     Heroku push rejected, failed to compile Ruby/rails app

To [email protected]:blazing-mountain-3659.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:blazing-mountain-3659.git'

When I do:

Amits-MacBook-Air-2:demo_app amitgupta$ sudo port install sqlite3 +universal

I get:

Password:
--->  Computing dependencies for sqlite3
--->  Cleaning sqlite3

Next I tried:

Amits-MacBook-Air-2:demo_app amitgupta$ sudo gem install sqlite3 -v '1.3.6'

And get:

Building native extensions.  This could take a while...
Successfully installed sqlite3-1.3.6
1 gem installed
Installing ri documentation for sqlite3-1.3.6...
Installing RDoc documentation for sqlite3-1.3.6...

Then:

Amits-MacBook-Air-2:demo_app amitgupta$ bundle install

gives:

Using rake (0.9.2.2) 
.
.
.
Using sqlite3 (1.3.6) 
Using uglifier (1.2.4) 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

Then I try pushing to Heroku again, but get the same problem. Perhaps it has something to do with the discrepancy between the first command "Creating floating-stream-8009" and the second command "failed to push some refs to '[email protected]:blazing-mountain-3659.git'"?

5 Answers 5

53
gem 'sqlite3', :group => [:development, :test]
group :production do
  gem 'pg'
end
  1. edit Gemfile as above
  2. remove Gemfile.lock
  3. run bundle install --without production
  4. git add .
  5. git commit -am "bundle updating sqlite3"
  6. git push heroku master
4
  • 4
    Thanx! This was the solution for me. Jul 9, 2012 at 22:44
  • 3
    Thank you. It fixed my problem though it was not chosen by the OP.
    – newguy
    Sep 13, 2012 at 0:22
  • 1
    kind explanation for newbies like me ;-) Sep 19, 2013 at 15:17
  • Nice. An explanation though of what is happening would be great!
    – Pithikos
    Dec 8, 2015 at 13:42
25

Heroku uses postgresql so you want to remove sqlite3 or move it into a development group in your Gemfile.

Check you Gemfile.lock for any other gems that may have dependencies on sqlite3, as this can also cause problems.

3
  • 1
    Once you remove sqlite3 from the gemfile, and save the gem file, and check gemfile.lock and confirm there are no other references to it - THEN - what are the next steps? I'm still pushing to Heroku and getting that same error - but I feel like it shouldn't be looking for sqlite3 now.
    – stopshinal
    Aug 28, 2012 at 21:27
  • 3
    @stopshinal dont forget to commit the changes in the gem file again locally before pushing it again into heroku Dec 25, 2012 at 19:34
  • @DanS, is there any formal document that indicates sqlite3 is not supported any more?
    – LiangWang
    Apr 7, 2015 at 22:57
4

I had a similar problem and I wasn't even using sqlite3 for anything but after removing it from the gem file I still got that error

what solved it for me was a commit command

git commit -am 

that I found on this tutorial

1

What happened to me was, I was following along the Heroku tutorial and when I used git push heroku master it was pushing from my latest Git commit (obviously!)

What I forgot was that in the eyes of Git, I was still using sqlite in the gemfile! Silly me!

So I used git add . followed by a git commit -m "Changed to Postgres." so Git knew about these changes. Pushing after that worked fine for me.

0

Yes, as these answers suggest, most of the time you will want to avoid using SQLite in production due to the constraints of the Heroku platform. However, you may have a perfectly acceptable use case (ex. read-only config) for using SQLite anyway. My recommendation is to:

  1. Add the heroku-buildpack-apt buildpack

  2. Add to your Aptfile:

    libsqlite3-dev
    libsqlite3-0
    

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.