Ruby
Rails
Heroku
Gemfile

Gemfile通りにherokuが'bundle install'してくれない!

More than 1 year has passed since last update.

何が起こってるのか

herokuではどうやら、 sqlite3は使えないそうなので本番とローカル環境でDBを切り分けるようGemfileを更新しました。

# Gemfile
source 'https://rubygems.org'

gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
gem 'pg'
gem 'puma', '~> 3.0'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'jquery-rails'
gem 'jbuilder', '~> 2.5'

group :development, :test do
  gem 'byebug', platform: :mri
  gem 'sqlite3'
end

group :development do
  gem 'web-console'
  gem 'listen', '~> 3.0.5'
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

developmenttestでは、sqliteを。
productionでは、pgを使うように修正しgit push heroku masterを実行!

だがだがだが、何度やってもsqliteをインストールしてきて失敗する。
bundle updatebundle exec bundle installやってもダメ。

そのエラーがこちら(長いけどログ全部です)

$ git push heroku master
Counting objects: 106, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (94/94), done.
Writing objects: 100% (106/106), 23.17 KiB | 1.78 MiB/s, done.
Total 106 (delta 5), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.3.4
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 older than the version that created the lockfile (1.15.4). We suggest you upgrade to the latest version of Bundler by running `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.org/.
remote:        Fetching rake 12.0.0
remote:        Fetching concurrent-ruby 1.0.5
remote:        Fetching i18n 0.8.6
remote:        Installing i18n 0.8.6
remote:        Installing rake 12.0.0
remote:        Installing concurrent-ruby 1.0.5
remote:        Fetching minitest 5.10.3
remote:        Fetching thread_safe 0.3.6
remote:        Installing minitest 5.10.3
remote:        Installing thread_safe 0.3.6
remote:        Fetching builder 3.2.3
remote:        Fetching erubis 2.7.0
remote:        Installing builder 3.2.3
remote:        Fetching mini_portile2 2.2.0
remote:        Fetching rack 2.0.3
remote:        Installing mini_portile2 2.2.0
remote:        Installing erubis 2.7.0
remote:        Fetching nio4r 2.1.0
remote:        Installing rack 2.0.3
remote:        Installing nio4r 2.1.0 with native extensions
remote:        Fetching websocket-extensions 0.1.2
remote:        Fetching mime-types-data 3.2016.0521
remote:        Installing websocket-extensions 0.1.2
remote:        Fetching arel 7.1.4
remote:        Installing arel 7.1.4
remote:        Installing mime-types-data 3.2016.0521
remote:        Using bundler 1.15.2
remote:        Fetching coffee-script-source 1.12.2
remote:        Fetching execjs 2.7.0
remote:        Installing coffee-script-source 1.12.2
remote:        Installing execjs 2.7.0
remote:        Fetching method_source 0.8.2
remote:        Fetching thor 0.20.0
remote:        Installing method_source 0.8.2
remote:        Installing thor 0.20.0
remote:        Fetching ffi 1.9.18
remote:        Fetching multi_json 1.12.1
remote:        Installing multi_json 1.12.1
remote:        Fetching puma 3.10.0
remote:        Installing puma 3.10.0 with native extensions
remote:        Installing ffi 1.9.18 with native extensions
remote:        Fetching rb-fsevent 0.10.2
remote:        Installing rb-fsevent 0.10.2
remote:        Fetching tilt 2.0.8
remote:        Installing tilt 2.0.8
remote:        Fetching sqlite3 1.3.13
remote:        Installing sqlite3 1.3.13 with native extensions
remote:        Fetching tzinfo 1.2.3
remote:        Installing tzinfo 1.2.3
remote:        Fetching nokogiri 1.8.0
remote:        Installing nokogiri 1.8.0 with native extensions
remote:        Fetching rack-test 0.6.3
remote:        Installing rack-test 0.6.3
remote:        Fetching sprockets 3.7.1
remote:        Installing sprockets 3.7.1
remote:        Fetching websocket-driver 0.6.5
remote:        Installing websocket-driver 0.6.5 with native extensions
remote:        Fetching mime-types 3.1
remote:        Installing mime-types 3.1
remote:        Fetching coffee-script 2.4.1
remote:        Installing coffee-script 2.4.1
remote:        Fetching uglifier 3.2.0
remote:        Installing uglifier 3.2.0
remote:        Fetching activesupport 5.0.5
remote:        Installing activesupport 5.0.5
remote:        Fetching rb-inotify 0.9.10
remote:        Installing rb-inotify 0.9.10
remote:        The latest bundler is 1.15.4, but you are currently running 1.15.2.
remote:        To update, run `gem install bundler`
remote:        Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
remote:        current directory:
remote:        /tmp/build_a4bf8c817c0f6961c0c3380fee8c4817/vendor/bundle/ruby/2.3.0/gems/sqlite3-1.3.13/ext/sqlite3
remote:        /tmp/build_a4bf8c817c0f6961c0c3380fee8c4817/vendor/ruby-2.3.4/bin/ruby -r
remote:        ./siteconf20170902-218-13nbpcr.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_a4bf8c817c0f6961c0c3380fee8c4817/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_a4bf8c817c0f6961c0c3380fee8c4817/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_a4bf8c817c0f6961c0c3380fee8c4817/vendor/bundle/ruby/2.3.0/gems/sqlite3-1.3.13
remote:        for inspection.
remote:        Results logged to
remote:        /tmp/build_a4bf8c817c0f6961c0c3380fee8c4817/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:        In Gemfile:
remote:        sqlite3
remote:        Bundler Output: Warning: the running version of Bundler (1.15.2) is older than the version that created the lockfile (1.15.4). We suggest you upgrade to the latest version of Bundler by running `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.org/.
remote:        Fetching rake 12.0.0
remote:        Fetching concurrent-ruby 1.0.5
remote:        Fetching i18n 0.8.6
remote:        Installing i18n 0.8.6
remote:        Installing rake 12.0.0
remote:        Installing concurrent-ruby 1.0.5
remote:        Fetching minitest 5.10.3
remote:        Fetching thread_safe 0.3.6
remote:        Installing minitest 5.10.3
remote:        Installing thread_safe 0.3.6
remote:        Fetching builder 3.2.3
remote:        Fetching erubis 2.7.0
remote:        Installing builder 3.2.3
remote:        Fetching mini_portile2 2.2.0
remote:        Fetching rack 2.0.3
remote:        Installing mini_portile2 2.2.0
remote:        Installing erubis 2.7.0
remote:        Fetching nio4r 2.1.0
remote:        Installing rack 2.0.3
remote:        Installing nio4r 2.1.0 with native extensions
remote:        Fetching websocket-extensions 0.1.2
remote:        Fetching mime-types-data 3.2016.0521
remote:        Installing websocket-extensions 0.1.2
remote:        Fetching arel 7.1.4
remote:        Installing arel 7.1.4
remote:        Installing mime-types-data 3.2016.0521
remote:        Using bundler 1.15.2
remote:        Fetching coffee-script-source 1.12.2
remote:        Fetching execjs 2.7.0
remote:        Installing coffee-script-source 1.12.2
remote:        Installing execjs 2.7.0
remote:        Fetching method_source 0.8.2
remote:        Fetching thor 0.20.0
remote:        Installing method_source 0.8.2
remote:        Installing thor 0.20.0
remote:        Fetching ffi 1.9.18
remote:        Fetching multi_json 1.12.1
remote:        Installing multi_json 1.12.1
remote:        Fetching puma 3.10.0
remote:        Installing puma 3.10.0 with native extensions
remote:        Installing ffi 1.9.18 with native extensions
remote:        Fetching rb-fsevent 0.10.2
remote:        Installing rb-fsevent 0.10.2
remote:        Fetching tilt 2.0.8
remote:        Installing tilt 2.0.8
remote:        Fetching sqlite3 1.3.13
remote:        Installing sqlite3 1.3.13 with native extensions
remote:        Fetching tzinfo 1.2.3
remote:        Installing tzinfo 1.2.3
remote:        Fetching nokogiri 1.8.0
remote:        Installing nokogiri 1.8.0 with native extensions
remote:        Fetching rack-test 0.6.3
remote:        Installing rack-test 0.6.3
remote:        Fetching sprockets 3.7.1
remote:        Installing sprockets 3.7.1
remote:        Fetching websocket-driver 0.6.5
remote:        Installing websocket-driver 0.6.5 with native extensions
remote:        Fetching mime-types 3.1
remote:        Installing mime-types 3.1
remote:        Fetching coffee-script 2.4.1
remote:        Installing coffee-script 2.4.1
remote:        Fetching uglifier 3.2.0
remote:        Installing uglifier 3.2.0
remote:        Fetching activesupport 5.0.5
remote:        Installing activesupport 5.0.5
remote:        Fetching rb-inotify 0.9.10
remote:        Installing rb-inotify 0.9.10
remote:        The latest bundler is 1.15.4, but you are currently running 1.15.2.
remote:        To update, run `gem install bundler`
remote:        Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
remote:
remote:        current directory:
remote:        /tmp/build_a4bf8c817c0f6961c0c3380fee8c4817/vendor/bundle/ruby/2.3.0/gems/sqlite3-1.3.13/ext/sqlite3
remote:        /tmp/build_a4bf8c817c0f6961c0c3380fee8c4817/vendor/ruby-2.3.4/bin/ruby -r
remote:        ./siteconf20170902-218-13nbpcr.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_a4bf8c817c0f6961c0c3380fee8c4817/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_a4bf8c817c0f6961c0c3380fee8c4817/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_a4bf8c817c0f6961c0c3380fee8c4817/vendor/bundle/ruby/2.3.0/gems/sqlite3-1.3.13
remote:        for inspection.
remote:        Results logged to
remote:        /tmp/build_a4bf8c817c0f6961c0c3380fee8c4817/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:        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 still-inlet-93643.
remote:
To https://git.heroku.com/still-inlet-93643.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/still-inlet-93643.git'

解決方法

$ bundle install --without production
Bundle complete! 15 Gemfile dependencies, 61 gems now installed.
Gems in the group production were not installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.

??なのだが、これやった後にheroku pushしたらでけた。

これやった前後の違いは、こいつが新たに出来上がった

# .bundle/config
---
BUNDLE_WITHOUT: "production"

これによってなんかきちんと設定を見るようになったんだと思う。

結構なはまりポイントだと思うので、何かお役に立てれば幸いです。