0

I'm trying to deploy my rails app to heroku, but due to constant errors when I do "git push heroku master," I've been unable to do it.The error appears this way:

$ git push heroku master
Counting objects: 8942, done.

Delta compression using up to 4 threads.
Compressing objects: 100% (8320/8320), done.
Writing objects: 100% (8942/8942), 38.02 MiB | 1.59 MiB/s, done.
Total 8942 (delta 1019), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote:  !     Warning: Multiple default buildpacks reported the abi
lity to handle this app. The first buildpack in the list below will
be used.
remote:                         Detected buildpacks: Ruby,Node.js
remote:                         See https://devcenter.heroku.com/art
icles/buildpacks#buildpack-detect-order
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.3.7
remote: -----> Installing dependencies using bundler 1.15.2
remote:        Running: bundle install --without development:test --
path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote:        Warning: the running version of Bundler (1.15.2) is o
lder than the version that created the lockfile (1.16.1). We suggest
 you upgrade to the latest version of Bundler by running `gem instal
l bundler`.
remote:        Fetching gem metadata from https://rubygems.org/.....
...
remote:        Fetching version metadata from https://rubygems.org/.
.
remote:        Fetching dependency metadata from https://rubygems.or
g/.
remote:        Fetching rake 12.3.1
remote:        Fetching concurrent-ruby 1.0.5
remote:        Fetching minitest 5.11.3
remote:        Installing rake 12.3.1
(...)
remote:        Installing activesupport 5.1.6
remote:        Gem::Ext::BuildError: ERROR: Failed to build gem nati
ve extension.
remote:
remote:        current directory:
remote:        /tmp/build_cffd92476daf50cbcc0ddddd7e5ac406/vendor/bu
ndle/ruby/2.3.0/gems/sqlite3-1.3.13/ext/sqlite3
remote:        /tmp/build_cffd92476daf50cbcc0ddddd7e5ac406/vendor/ru
by-2.3.7/bin/ruby -r
remote:        ./siteconf20180513-253-1utdlov.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 libsql
ite3-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, probabl
y lack of necessary
remote:        libraries and/or headers.  Check the mkmf.log file fo
r 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:         --srcdir=.

remote:         --curdir
remote:        --ruby=/tmp/build_cffd92476daf50cbcc0ddddd7e5ac406/ve
ndor/ruby-2.3.7/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 c
heck the mkmf.log which can
remote:        be found here:
remote:
remote:        /tmp/build_cffd92476daf50cbcc0ddddd7e5ac406/vendor/bu
ndle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/sqlite3-1.3.13/mkmf.lo
g
remote:
remote:        extconf failed, exit code 1
remote:
remote:        Gem files will remain installed in
remote:        /tmp/build_cffd92476daf50cbcc0ddddd7e5ac406/vendor/bu
ndle/ruby/2.3.0/gems/sqlite3-1.3.13
remote:        for inspection.
remote:        Results logged to
remote:        /tmp/build_cffd92476daf50cbcc0ddddd7e5ac406/vendor/bu
ndle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/sqlite3-1.3.13/gem_mak
e.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'` succ
eeds before bundling.
remote:
remote:        In Gemfile:
remote:          sqlite3
remote:        Bundler Output: Warning: the running version of Bundl
er (1.15.2) is older than the version that created the lockfile (1.1
6.1). We suggest you upgrade to the latest version of Bundler by run
ning `gem install bundler`.
remote:        Fetching gem metadata from https://rubygems.org/.....
...
remote:        Fetching version metadata from https://rubygems.org/.
.
remote:        Fetching dependency metadata from https://rubygems.or
g/.
remote:        Fetching rake 12.3.1
remote:        Fetching concurrent-ruby 1.0.5
(...)
remote:        Installing activesupport 5.1.6
remote:        Gem::Ext::BuildError: ERROR: Failed to build gem nati
ve extension.
remote:
remote:        current directory:
remote:        /tmp/build_cffd92476daf50cbcc0ddddd7e5ac406/vendor/bu
ndle/ruby/2.3.0/gems/sqlite3-1.3.13/ext/sqlite3
remote:        /tmp/build_cffd92476daf50cbcc0ddddd7e5ac406/vendor/ru
by-2.3.7/bin/ruby -r
remote:        ./siteconf20180513-253-1utdlov.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 libsql
ite3-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, probabl
y lack of necessary
remote:        libraries and/or headers.  Check the mkmf.log file fo
r 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_cffd92476daf50cbcc0ddddd7e5ac406/ve
ndor/ruby-2.3.7/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 c
heck the mkmf.log which can
remote:        be found here:
remote:
remote:        /tmp/build_cffd92476daf50cbcc0ddddd7e5ac406/vendor/bu
ndle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/sqlite3-1.3.13/mkmf.lo
g
remote:
remote:        extconf failed, exit code 1
remote:
remote:        Gem files will remain installed in
remote:        /tmp/build_cffd92476daf50cbcc0ddddd7e5ac406/vendor/bu
ndle/ruby/2.3.0/gems/sqlite3-1.3.13
remote:        for inspection.
remote:        Results logged to
remote:        /tmp/build_cffd92476daf50cbcc0ddddd7e5ac406/vendor/bu
ndle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/sqlite3-1.3.13/gem_mak
e.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'` succ
eeds before bundling.
remote:
remote:        In Gemfile:
remote:          sqlite3
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:
remote: !       Push rejected to XXXXX.
remote:
To https://git.heroku.com/XXXXX.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/XXXXX.git'

My Gemfile is below [updated]:

source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.6'

group :production do
  gem 'pg'
end

# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '~> 2.13'
  gem 'selenium-webdriver'

  gem 'pry-rails'  
  gem 'pry-doc'    
  gem 'pry-byebug' 
  gem 'pry-stack_explorer' 
  gem 'hirb'         
  gem 'hirb-unicode' 
  gem 'better_errors'
  gem "binding_of_caller"

  # Use sqlite3 as the database for Active Record
  gem 'sqlite3', require: false
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

gem 'devise'

gem 'omniauth-facebook'

gem 'dotenv-rails', require: 'dotenv/rails-now'

gem 'thin'

gem 'carrierwave'

gem 'rails-erd'

gem 'jquery-rails'

I'm a beginner developer of ruby-on-rails and totally at a loss what to do to fix this problem. Any help is so appreciated!

Yoshiaki
  • 180
  • 1
  • 11

3 Answers3

0

First, make sure you have the gemfile right, it should be something like this:

group :production do  
  gem 'pg'
end

run

bundle install

Editin config/database.yml

development:
 adapter: sqlite3
 database: db/development.sqlite3
 pool: 5
 timeout: 5000

test:
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

production:
  adapter: postgresql
  database: my_database_production
  pool: 5
  timeout: 5000

And finally commit the changes

git commit -am 'changes'

upload the changes to heroku

git push heroku master

Make sure you create the bd in heroku

heroku addons:create heroku-postgresql

this article can help you https://devcenter.heroku.com/articles/sqlite3

Andres23Ramirez
  • 547
  • 1
  • 3
  • 12
  • Hi, thanks for your support! I've inserted "gem 'pg'" in group :production like your advise and conducted `git push heroku master` again, the situation remains unchanged. The error messages are completely same. – Yoshiaki May 13 '18 at 19:41
  • I've followed your instruction, but unfortunately the situation is the same... The error message still indicates `checking for sqlite3.h... no`. I've also followed the instruction below but the result is the same... https://stackoverflow.com/questions/41370565/ruby-sqlite3-installation-sqlite3-libversion-number-macos-sierra – Yoshiaki May 13 '18 at 20:32
  • In development can you work with another bd, like pg or mysql? – Andres23Ramirez May 13 '18 at 20:38
0

Documented on Heroku's website. (https://devcenter.heroku.com/articles/sqlite3#getting-a-sqlite-error-even-though-it-is-not-in-the-gemfile). Your database.yml should look like this:

development:
 adapter: postgresql
 database: my_database_development
 pool: 5
 timeout: 5000

test:
 adapter: postgresql
 database: my_database_test
 pool: 5
 timeout: 5000

production:
 adapter: postgresql
 database: my_database_production
 pool: 5
 timeout: 5000

After making those changes make sure to run the following commands:

rake db:create
rake db:migrate

Now you need to git add and git commit -m postgres. In the event you are still getting an error after trying all these steps, you may have to get your hands dirty and do some investigating as one of the gems you have in your gemfile could very well be using SQL as a dependency. Start with looking in your Gemfile.lock. Please see below:

Getting a SQLite error even though it is not in the Gemfile: If you’ve removed the gem 'sqlite3' line from your Gemfile and are still getting errors while deploying to Heroku it is likely that another gem you are using has sqlite3 as a dependency. To help find the source of this dependency look in your Gemfile.lock for sqlite3. 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.

Hope that helps.

kparekh01
  • 221
  • 1
  • 7
  • Thanks for your help. I've typed `gem dependency sqlite3` and found out that the gems below are dependent on it: `hoe (~> 3.15, development) hoe-bundler (~> 1.0, development) mini_portile (~> 0.6.2, development) minitest (~> 5.9, development) rake-compiler (~> 0.9.3, development) rake-compiler-dock (~> 0.5.2, development) rdoc (~> 4.0, development)` But the problem is that even if I try to execute `gem uninstall xxx(e.g. hoe)` it says "Gem 'hoe' is not installed." What should I do? – Yoshiaki May 14 '18 at 01:27
  • That command only lists what a gem's dependencies actually are. This does not mean they are integrated in your project. You must go to your `Gemfile.lock` and take a look at those dependencies and see if you can find any gems that may be requiring `sqlite3` as a dependency. Any gem you suspect, go to the github repo and check out their dependencies(ie: gemfile) to see if sqlite3 is one. – kparekh01 May 14 '18 at 14:02
0

Oh finally it turns out that the problem has been solved! I was in a development branch of my git and when I merged it into master and conducted git push heroku master, it went well. I hadn't realized the problem was caused by an easy factor until I read below. Thank you so much for your help!

c.f. Heroku installing sqlite3 even though it is not a dependecy

Yoshiaki
  • 180
  • 1
  • 11