1

I am trying to push my app to heroku, but I could not prevent it from installing sqlite3 - I believe this is what is causing the problem pushing it.

I have read and applied the following SO posts:

I have also made sure to commit my work:

git add .
git commit -m "sqlite3 problem"
git push heroku master

I tried deleting the Gemfile.lock and running both bundle and bundle install and add, commit, and pushed it to heroku, but still no luck.

This is inside my Gemfile:

group :production do
  gem 'pg'
end
group :development, :test do
  gem 'byebug', platform: :mri
  gem 'faker', '~> 1.7', '>= 1.7.3'
  gem 'rspec-rails', '~> 3.5'
  gem 'factory_girl_rails', '~> 4.8'
  gem 'sqlite3'
end

Error log:

remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.3.4
remote: -----> Installing dependencies using bundler 1.13.7
remote:        Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote:        Fetching gem metadata from https://rubygems.org/...........
remote:        Fetching version metadata from https://rubygems.org/..
remote:        Fetching dependency metadata from https://rubygems.org/.
remote:        Installing i18n 0.8.1
remote:        Installing rake 12.0.0
remote:        Installing concurrent-ruby 1.0.5
remote:        Installing minitest 5.10.1
remote:        Installing thread_safe 0.3.6
remote:        Installing builder 3.2.3
remote:        Installing erubis 2.7.0
remote:        Installing mini_portile2 2.1.0
remote:        Installing nio4r 2.0.0 with native extensions
remote:        Installing rack 2.0.1
remote:        Installing websocket-extensions 0.1.2
remote:        Installing mime-types-data 3.2016.0521
remote:        Installing arel 7.1.4
remote:        Installing connection_pool 2.2.1
remote:        Installing thor 0.19.4
remote:        Installing jwt 1.5.6
remote:        Installing method_source 0.8.2
remote:        Installing multi_json 1.12.1
remote:        Using bundler 1.13.7
remote:        Installing puma 3.8.2 with native extensions
remote:        Installing redis 3.3.3
remote:        Installing sqlite3 1.3.13 with native extensions
remote:        Installing tzinfo 1.2.3
remote:        Installing nokogiri 1.7.1 with native extensions
remote:        Installing rack-test 0.6.3
remote:        Installing rack-protection 2.0.0
remote:        Installing sprockets 3.7.1
remote:        Installing websocket-driver 0.6.5 with native extensions
remote:        Installing mime-types 3.1
remote:        Installing foreman 0.84.0
remote:        Installing twilio-ruby 4.11.1
remote:        Installing activesupport 5.0.2
remote:        Installing sidekiq 5.0.0
remote:        Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
remote:        current directory:
remote:        /tmp/build_cb97a281aec933a41e755d6b82c2e524/vendor/bundle/ruby/2.3.0/gems/sqlite3-1.3.13/ext/sqlite3
remote:        /tmp/build_cb97a281aec933a41e755d6b82c2e524/vendor/ruby-2.3.4/bin/ruby -r
remote:        ./siteconf20170606-219-133actd.rb extconf.rb
remote:        checking for sqlite3.h... no
remote:        sqlite3.h is missing. Try 'brew install sqlite3',
remote:        'yum install sqlite-devel' or 'apt-get install libsqlite3-dev'
remote:        and check your shared library search path (the
remote:        location where your sqlite3 shared library is located).
remote:        *** extconf.rb failed ***
remote:        Could not create Makefile due to some reason, probably lack of necessary
remote:        libraries and/or headers.  Check the mkmf.log file for more details.  You may
remote:        need configuration options.
remote:        Provided configuration options:
remote:        --with-opt-dir
remote:        --without-opt-dir
remote:        --with-opt-include
remote:        --without-opt-include=${opt-dir}/include
remote:        --with-opt-lib
remote:        --without-opt-lib=${opt-dir}/lib
remote:        --with-make-prog
remote:        --without-make-prog
remote:        --srcdir=.
remote:        --curdir
remote:        --ruby=/tmp/build_cb97a281aec933a41e755d6b82c2e524/vendor/ruby-2.3.4/bin/$(RUBY_BASE_NAME)
remote:        --with-sqlite3-config
remote:        --without-sqlite3-config
remote:        --with-pkg-config
remote:        --without-pkg-config
remote:        --with-sqlite3-dir
remote:        --without-sqlite3-dir
remote:        --with-sqlite3-include
remote:        --without-sqlite3-include=${sqlite3-dir}/include
remote:        --with-sqlite3-lib
remote:        --without-sqlite3-lib=${sqlite3-dir}/lib
remote:        To see why this extension failed to compile, please check the mkmf.log which can
remote:        be found here:
remote:        /tmp/build_cb97a281aec933a41e755d6b82c2e524/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/sqlite3-1.3.13/mkmf.log
remote:        extconf failed, exit code 1
remote:        Gem files will remain installed in
remote:        /tmp/build_cb97a281aec933a41e755d6b82c2e524/vendor/bundle/ruby/2.3.0/gems/sqlite3-1.3.13
remote:        for inspection.
remote:        Results logged to
remote:        /tmp/build_cb97a281aec933a41e755d6b82c2e524/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/sqlite3-1.3.13/gem_make.out
remote:        An error occurred while installing sqlite3 (1.3.13), and Bundler cannot
remote:        continue.
remote:        Make sure that `gem install sqlite3 -v '1.3.13'` succeeds before bundling.
remote:        Bundler Output: Fetching gem metadata from https://rubygems.org/...........
remote:        Fetching version metadata from https://rubygems.org/..
remote:        Fetching dependency metadata from https://rubygems.org/.
remote:        Installing i18n 0.8.1
remote:        Installing rake 12.0.0
remote:        Installing concurrent-ruby 1.0.5
remote:        Installing minitest 5.10.1
remote:        Installing thread_safe 0.3.6
remote:        Installing builder 3.2.3
remote:        Installing erubis 2.7.0
remote:        Installing mini_portile2 2.1.0
remote:        Installing nio4r 2.0.0 with native extensions
remote:        Installing rack 2.0.1
remote:        Installing websocket-extensions 0.1.2
remote:        Installing mime-types-data 3.2016.0521
remote:        Installing arel 7.1.4
remote:        Installing connection_pool 2.2.1
remote:        Installing thor 0.19.4
remote:        Installing jwt 1.5.6
remote:        Installing method_source 0.8.2
remote:        Installing multi_json 1.12.1
remote:        Using bundler 1.13.7
remote:        Installing puma 3.8.2 with native extensions
remote:        Installing redis 3.3.3
remote:        Installing sqlite3 1.3.13 with native extensions
remote:        Installing tzinfo 1.2.3
remote:        Installing nokogiri 1.7.1 with native extensions
remote:        Installing rack-test 0.6.3
remote:        Installing rack-protection 2.0.0
remote:        Installing sprockets 3.7.1
remote:        Installing websocket-driver 0.6.5 with native extensions
remote:        Installing mime-types 3.1
remote:        Installing foreman 0.84.0
remote:        Installing twilio-ruby 4.11.1
remote:        Installing activesupport 5.0.2
remote:        Installing sidekiq 5.0.0
remote:        Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
remote:        
remote:        current directory:
remote:        /tmp/build_cb97a281aec933a41e755d6b82c2e524/vendor/bundle/ruby/2.3.0/gems/sqlite3-1.3.13/ext/sqlite3
remote:        /tmp/build_cb97a281aec933a41e755d6b82c2e524/vendor/ruby-2.3.4/bin/ruby -r
remote:        ./siteconf20170606-219-133actd.rb extconf.rb
remote:        checking for sqlite3.h... no
remote:        sqlite3.h is missing. Try 'brew install sqlite3',
remote:        'yum install sqlite-devel' or 'apt-get install libsqlite3-dev'
remote:        and check your shared library search path (the
remote:        location where your sqlite3 shared library is located).
remote:        *** extconf.rb failed ***
remote:        Could not create Makefile due to some reason, probably lack of necessary
remote:        libraries and/or headers.  Check the mkmf.log file for more details.  You may
remote:        need configuration options.
remote:        
remote:        Provided configuration options:
remote:        --with-opt-dir
remote:        --without-opt-dir
remote:        --with-opt-include
remote:        --without-opt-include=${opt-dir}/include
remote:        --with-opt-lib
remote:        --without-opt-lib=${opt-dir}/lib
remote:        --with-make-prog
remote:        --without-make-prog
remote:        --srcdir=.
remote:        --curdir
remote:        --ruby=/tmp/build_cb97a281aec933a41e755d6b82c2e524/vendor/ruby-2.3.4/bin/$(RUBY_BASE_NAME)
remote:        --with-sqlite3-config
remote:        --without-sqlite3-config
remote:        --with-pkg-config
remote:        --without-pkg-config
remote:        --with-sqlite3-dir
remote:        --without-sqlite3-dir
remote:        --with-sqlite3-include
remote:        --without-sqlite3-include=${sqlite3-dir}/include
remote:        --with-sqlite3-lib
remote:        --without-sqlite3-lib=${sqlite3-dir}/lib
remote:        
remote:        To see why this extension failed to compile, please check the mkmf.log which can
remote:        be found here:
remote:        
remote:        /tmp/build_cb97a281aec933a41e755d6b82c2e524/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/sqlite3-1.3.13/mkmf.log
remote:        
remote:        extconf failed, exit code 1
remote:        
remote:        Gem files will remain installed in
remote:        /tmp/build_cb97a281aec933a41e755d6b82c2e524/vendor/bundle/ruby/2.3.0/gems/sqlite3-1.3.13
remote:        for inspection.
remote:        Results logged to
remote:        /tmp/build_cb97a281aec933a41e755d6b82c2e524/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/sqlite3-1.3.13/gem_make.out
remote:        
remote:        An error occurred while installing sqlite3 (1.3.13), and Bundler cannot
remote:        continue.
remote:        Make sure that `gem install sqlite3 -v '1.3.13'` succeeds before bundling.
remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !     Detected sqlite3 gem which is not supported on Heroku:
remote:  !     https://devcenter.heroku.com/articles/sqlite3
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 

Every single time, I keep seeing this line Installing sqlite3 1.3.13 with native extensions and I believe that is what caused the error, even though I don't have sqlite3 in production. I have also tried removing sqlite3 altogether from Gemfile and have only gem pg, but it still somehow installs sqlite3 when I push it to heroku.

How can I push the app to heroku successfully?

EDIT:

The problem is solved (well, technically not - I am still having trouble pushing, but the sqlite3 error disappeared, and that's the gist of this question). Here is what I did wrong: I was working on other local branch when I see the error message, let's say iggy-branch-2. I did my git add ., git commit -m "some message", and git push heroku master on this branch. When I switched back to master branch and git merge iggy-branch-2, and after I git push heroku master, it stopped trying to install sqlite3. It appears that when I push to heroku, it looks for gemfile.lock inside master branch (someone correct me if I'm wrong).

The comments and answer here gave me the insight that the only way to update gemfile.lock is really just to bundle it up. I figured I did all the right thing, so I decided to try switching branches.

Take-home: make sure my master branch is up-to-date. Seems like Heroku looks there for gemfile info.

Thanks, everyone!

Iggy
  • 5,129
  • 12
  • 53
  • 87

2 Answers2

0

This is because herouku uses your gemfile.lock to know the gems and versions to use instead of the gemfile, you must:

  1. run a bundle install locally to update your gemfile.lock
  2. commit and push that change to git(hub)
  3. push to heroku.

Good luck!

Edit: Also, make sure to include your gemfile.lock to git, although that's kind of obvious

Eduardo Veras
  • 961
  • 1
  • 7
  • 20
0

When you do git push heroku master, it pushes your local master branch onto the master branch of the heroku remote (no matter which local branch is currently checked out).

If you are working on a different branch, say 'feature/foo' and you want to deploy that branch, you need to tell git explicitly by doing git push feature/foo:master

Another way, from the git push documentation:

git push origin HEAD:master

Push the current branch to the remote ref matching master in the origin repository. This form is convenient to push the current branch without thinking about its local name.

As you correctly guessed, the problem was that you were working on a branch but deploying master. This is why merging to master before deploying also solved the problem.

Community
  • 1
  • 1
KevinG
  • 882
  • 3
  • 16
  • 33