【发布时间】:2017-11-08 02:55:37
【问题描述】:
我正在尝试将我的应用推送到 heroku,但我无法阻止它安装 sqlite3 - 我相信这是导致推送问题的原因。
我已阅读并应用了以下 SO 帖子:
- Deploying RoR app to Heroku with Sqlite3 fails
- HEROKU - cannot run git push heroku master
- Unable to Deploy Rails App to Heroku, Gem Errors (SQLite3 and Gem Native Extension)
我也确保了我的工作:
git add .
git commit -m "sqlite3 problem"
git push heroku master
我尝试删除 Gemfile.lock 并同时运行 bundle 和 bundle install 并添加、提交并将其推送到 heroku,但仍然没有运气。
这是在我的 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
错误日志:
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:
每一次,我都会看到这条线Installing sqlite3 1.3.13 with native extensions,我相信这是导致错误的原因,即使我没有在生产中使用 sqlite3。我还尝试从 Gemfile 中完全删除 sqlite3,并且只有 gem pg,但是当我将它推送到 heroku 时,它仍然以某种方式安装了 sqlite3。
如何将应用成功推送到heroku?
编辑:
问题已解决(嗯,技术上不是 - 我仍然无法推送,但是 sqlite3 错误消失了,这就是这个问题的要点)。这是我做错的地方:当我看到错误消息时,我正在其他本地分支上工作,比如说 iggy-branch-2。我在这个分支上做了我的git add ., git commit -m "some message", and git push heroku master。当我切换回master 分支和git merge iggy-branch-2 时,在我git push heroku master 之后,它停止尝试安装sqlite3。看来,当我推送到 heroku 时,它会在 master 分支中查找 gemfile.lock(如果我错了,请有人纠正我)。
这里的 cmets 和答案让我了解到,更新 gemfile.lock 的唯一方法实际上就是将其捆绑起来。我认为我做的一切都是正确的,所以我决定尝试切换分支。
带回家:确保我的 master 分支是最新的。似乎 Heroku 在那里寻找 gemfile 信息。
谢谢大家!
【问题讨论】:
-
执行“捆绑安装”以更新 Gemfile.lock。你能粘贴你的database.yml
标签: ruby-on-rails heroku sqlite