【问题标题】:Heroku: Failed to install gems via Bundler - Trouble deploying to HerokuHeroku:无法通过 Bundler 安装 gem - 无法部署到 Heroku
【发布时间】:2018-07-18 06:14:29
【问题描述】:

在过去的几个小时里,我一直在尝试使用 git push heroku master 将我的 Rails 应用程序推送到 Heroku,但遇到了问题。这是输出:

remote: Compressing source files... done.
remote: Building source:
remote: 
remote:  !     Warning: Multiple default buildpacks reported the ability 
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/articles/buildpacks#buildpack-detect-order
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.4.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.16.3). 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.3.1
remote:        Fetching concurrent-ruby 1.0.5
remote:        Fetching minitest 5.11.3
remote:        Installing minitest 5.11.3
remote:        Installing rake 12.3.1
remote:        Installing concurrent-ruby 1.0.5
remote:        Fetching thread_safe 0.3.6
remote:        Installing thread_safe 0.3.6
remote:        Fetching builder 3.2.3
remote:        Installing builder 3.2.3
remote:        Fetching erubi 1.7.1
remote:        Fetching mini_portile2 2.3.0
remote:        Installing erubi 1.7.1
remote:        Installing mini_portile2 2.3.0
remote:        Fetching crass 1.0.4
remote:        Fetching rack 2.0.5
remote:        Installing crass 1.0.4
remote:        Fetching nio4r 2.3.1
remote:        Installing nio4r 2.3.1 with native extensions
remote:        Installing rack 2.0.5
remote:        Fetching websocket-extensions 0.1.3
remote:        Installing websocket-extensions 0.1.3
remote:        Fetching mini_mime 1.0.0
remote:        Installing mini_mime 1.0.0
remote:        Fetching arel 8.0.0
remote:        Installing arel 8.0.0
remote:        Fetching execjs 2.7.0
remote:        Fetching bcrypt 3.1.12
remote:        Installing execjs 2.7.0
remote:        Installing bcrypt 3.1.12 with native extensions
remote:        Fetching rb-fsevent 0.10.3
remote:        Installing rb-fsevent 0.10.3
remote:        Fetching ffi 1.9.25
remote:        Installing ffi 1.9.25 with native extensions
remote:        Using bundler 1.15.2
remote:        Fetching chronic 0.10.2
remote:        Installing chronic 0.10.2
remote:        Fetching coffee-script-source 1.12.2
remote:        Installing coffee-script-source 1.12.2
remote:        Fetching method_source 0.9.0
remote:        Installing method_source 0.9.0
remote:        Fetching thor 0.20.0
remote:        Installing thor 0.20.0
remote:        Fetching orm_adapter 0.5.0
remote:        Installing orm_adapter 0.5.0
remote:        Fetching devise-bootstrapped 0.1.1
remote:        Installing devise-bootstrapped 0.1.1
remote:        Fetching multi_json 1.13.1
remote:        Installing multi_json 1.13.1
remote:        Fetching puma 3.12.0
remote:        Installing puma 3.12.0 with native extensions
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 turbolinks-source 5.1.0
remote:        Installing turbolinks-source 5.1.0
remote:        Fetching i18n 1.0.1
remote:        Installing i18n 1.0.1
remote:        Fetching tzinfo 1.2.5
remote:        Installing tzinfo 1.2.5
remote:        Fetching nokogiri 1.8.4
remote:        Installing nokogiri 1.8.4 with native extensions
remote:        Fetching websocket-driver 0.6.5
remote:        Installing websocket-driver 0.6.5 with native extensions
remote:        Fetching mail 2.7.0
remote:        Installing mail 2.7.0
remote:        Fetching rack-test 1.0.0
remote:        Installing rack-test 1.0.0
remote:        Fetching warden 1.2.7
remote:        Installing warden 1.2.7
remote:        Fetching sprockets 3.7.2
remote:        Installing sprockets 3.7.2
remote:        Fetching autoprefixer-rails 9.0.0
remote:        Installing autoprefixer-rails 9.0.0
remote:        Fetching uglifier 4.1.15
remote:        Installing uglifier 4.1.15
remote:        Fetching whenever 0.10.0
remote:        Installing whenever 0.10.0
remote:        Fetching coffee-script 2.4.1
remote:        Installing coffee-script 2.4.1
remote:        Fetching rb-inotify 0.9.10
remote:        Installing rb-inotify 0.9.10
remote:        Fetching turbolinks 5.1.1
remote:        Installing turbolinks 5.1.1
remote:        Fetching faker 1.9.1
remote:        Installing faker 1.9.1
remote:        Fetching activesupport 5.1.6
remote:        Installing activesupport 5.1.6
remote:        Gem::Ext::BuildError: ERROR: Failed to build gem native 
extension.
remote:        
remote:        current directory:
remote:       
remote:        /tmp/build_4bda83927de17e82c06097acea1b6b55/vendor/ruby- 
2.4.4/bin/ruby -r
remote:        ./siteconf20180718-265-17bd8cb.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_4bda83927de17e82c06097acea1b6b55/vendor/ruby- 
2.4.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:        
remote:        
remote:        extconf failed, exit code 1
remote:        
remote:        Gem files will remain installed in
remote:        
remote:        for inspection.
remote:        Results logged to
remote:        
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:        Bundler Output: Warning: the running version of Bundler 
(1.15.2) is older than the version that created the lockfile (1.16.3). 
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.3.1
remote:        Fetching concurrent-ruby 1.0.5
remote:        Fetching minitest 5.11.3
remote:        Installing minitest 5.11.3
remote:        Installing rake 12.3.1
remote:        Installing concurrent-ruby 1.0.5
remote:        Fetching thread_safe 0.3.6
remote:        Installing thread_safe 0.3.6
remote:        Fetching builder 3.2.3
remote:        Installing builder 3.2.3
remote:        Fetching erubi 1.7.1
remote:        Fetching mini_portile2 2.3.0
remote:        Installing erubi 1.7.1
remote:        Installing mini_portile2 2.3.0
remote:        Fetching crass 1.0.4
remote:        Fetching rack 2.0.5
remote:        Installing crass 1.0.4
remote:        Fetching nio4r 2.3.1
remote:        Installing nio4r 2.3.1 with native extensions
remote:        Installing rack 2.0.5
remote:        Fetching websocket-extensions 0.1.3
remote:        Installing websocket-extensions 0.1.3
remote:        Fetching mini_mime 1.0.0
remote:        Installing mini_mime 1.0.0
remote:        Fetching arel 8.0.0
remote:        Installing arel 8.0.0
remote:        Fetching execjs 2.7.0
remote:        Fetching bcrypt 3.1.12
remote:        Installing execjs 2.7.0
remote:        Installing bcrypt 3.1.12 with native extensions
remote:        Fetching rb-fsevent 0.10.3
remote:        Installing rb-fsevent 0.10.3
remote:        Fetching ffi 1.9.25
remote:        Installing ffi 1.9.25 with native extensions
remote:        Using bundler 1.15.2
remote:        Fetching chronic 0.10.2
remote:        Installing chronic 0.10.2
remote:        Fetching coffee-script-source 1.12.2
remote:        Installing coffee-script-source 1.12.2
remote:        Fetching method_source 0.9.0
remote:        Installing method_source 0.9.0
remote:        Fetching thor 0.20.0
remote:        Installing thor 0.20.0
remote:        Fetching orm_adapter 0.5.0
remote:        Installing orm_adapter 0.5.0
remote:        Fetching devise-bootstrapped 0.1.1
remote:        Installing devise-bootstrapped 0.1.1
remote:        Fetching multi_json 1.13.1
remote:        Installing multi_json 1.13.1
remote:        Fetching puma 3.12.0
remote:        Installing puma 3.12.0 with native extensions
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 turbolinks-source 5.1.0
remote:        Installing turbolinks-source 5.1.0
remote:        Fetching i18n 1.0.1
remote:        Installing i18n 1.0.1
remote:        Fetching tzinfo 1.2.5
remote:        Installing tzinfo 1.2.5
remote:        Fetching nokogiri 1.8.4
remote:        Installing nokogiri 1.8.4 with native extensions
remote:        Fetching websocket-driver 0.6.5
remote:        Installing websocket-driver 0.6.5 with native extensions
remote:        Fetching mail 2.7.0
remote:        Installing mail 2.7.0
remote:        Fetching rack-test 1.0.0
remote:        Installing rack-test 1.0.0
remote:        Fetching warden 1.2.7
remote:        Installing warden 1.2.7
remote:        Fetching sprockets 3.7.2
remote:        Installing sprockets 3.7.2
remote:        Fetching autoprefixer-rails 9.0.0
remote:        Installing autoprefixer-rails 9.0.0
remote:        Fetching uglifier 4.1.15
remote:        Installing uglifier 4.1.15
remote:        Fetching whenever 0.10.0
remote:        Installing whenever 0.10.0
remote:        Fetching coffee-script 2.4.1
remote:        Installing coffee-script 2.4.1
remote:        Fetching rb-inotify 0.9.10
remote:        Installing rb-inotify 0.9.10
remote:        Fetching turbolinks 5.1.1
remote:        Installing turbolinks 5.1.1
remote:        Fetching faker 1.9.1
remote:        Installing faker 1.9.1
remote:        Fetching activesupport 5.1.6
remote:        Installing activesupport 5.1.6
remote:        Gem::Ext::BuildError: ERROR: Failed to build gem native 
extension.
remote:        
remote:        current directory:
remote:        
remote:        /tmp/build_4bda83927de17e82c06097acea1b6b55/vendor/ruby- 
2.4.4/bin/ruby -r
remote:        ./siteconf20180718-265-17bd8cb.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:        --
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:        
remote:        
remote:        extconf failed, exit code 1
remote:        
remote:        Gem files will remain installed in
remote:        
remote:        for inspection.
remote:        Results logged to
remote:        
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:  !
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 glacial-reaches-77008.
remote: 
To https://git.heroku.com/glacial-reaches-77008.git
! [remote rejected] master -> master (pre-receive hook declined)

我再次尝试了bundle updatebundle install 并运行了git push heroku master,但它仍然没有做任何事情。

我还尝试删除我的 Gemfile.lock 文件,再次运行 bundle updatebundle installgit addgit commit 并运行 git push heroku master,但没有任何结果。

这是我的 Gemfile 的副本:

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.4'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# 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

gem 'bootstrap-sass', '~> 3.3.7'
gem 'jquery-rails'
gem 'growlyflash'

gem 'devise'
gem 'devise-bootstrapped'
gem 'whenever', require: false

gem 'faker'

# 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', '~> 3.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 'binding_of_caller'
  gem 'better_errors'

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]

这是我的 .gitignore

# See https://help.github.com/articles/ignoring-files for more about 
ignoring files.
#
# If you find yourself ignoring temporary files generated by your text 
editor
# or operating system, you probably want to add a global ignore instead:
#   git config --global core.excludesfile '~/.gitignore_global'

# Ignore bundler config.
/.bundle

# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep

/node_modules
/yarn-error.log

.byebug_history

我还删除了我的 Gemfile.lock rm -rf ~/.bundle/ ~/.gem/ .bundle/ Gemfile.lock,运行 bundle install``git addgit commit 并尝试再次将其推送到 Heroku,但没有成功。

【问题讨论】:

  • 您需要关注最初的博客,以便在 heroku 上进行项目部署。不支持 sqlite,应该使用 Postgres。替换 gem 并根据需要进行适当的代码更改。

标签: ruby-on-rails ruby heroku gemfile ruby-on-rails-5.1


【解决方案1】:

Heroku 无法安装 sqlite3 gem,因此您需要在生产环境中将其替换为 pg gem。像这样更改您的 Gemfile:

group :development, :test do
 gem 'sqlite3'
end

group :production do
 gem 'pg'
end

【讨论】:

    猜你喜欢
    • 2015-09-23
    • 2019-01-07
    • 2021-08-27
    • 1970-01-01
    • 2015-05-05
    • 1970-01-01
    • 2021-08-26
    • 2011-06-02
    相关资源
    最近更新 更多