【问题标题】:git push heroku master rails errorgit push heroku master rails 错误
【发布时间】:2016-02-19 05:07:57
【问题描述】:

我正在尝试将我的新 Rails 应用程序推送到 Heroku,但它不起作用。我尝试了很多东西,例如:

  1. 删除 Gemfile.lock 并创建另一个
  2. 运行 bundle install 和 bundle install --without production
  3. 重新安装 gem 'pg' 和 'rails_12factor'

当我输入 git push heroku master 时,这就是命令行中出现的内容:

    Counting objects: 87, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (73/73), done.
Writing objects: 100% (87/87), 18.46 KiB | 0 bytes/s, done.
Total 87 (delta 8), 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.0.0
remote: -----> Installing dependencies using bundler 1.9.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:        Rubygems 2.0.14 is not threadsafe, so your gems must be installed one at a time. Upgrade to Rubygems 2.1.0 or higher to enable parallel gem installation.
remote:        Installing rake 10.4.2
remote:        Installing i18n 0.7.0
remote:        Installing json 1.8.3
remote:        Installing minitest 5.8.2
remote:        Installing thread_safe 0.3.5
remote:        Installing tzinfo 1.2.2
remote:        Installing activesupport 4.2.4
remote:        Installing builder 3.2.2
remote:        Installing erubis 2.7.0
remote:        Installing mini_portile 0.6.2
remote:        Installing nokogiri 1.6.6.2
remote:        Installing rails-deprecated_sanitizer 1.0.3
remote:        Installing rails-dom-testing 1.0.7
remote:        Installing loofah 2.0.3
remote:        Installing rails-html-sanitizer 1.0.2
remote:        Installing actionview 4.2.4
remote:        Installing rack 1.6.4
remote:        Installing rack-test 0.6.3
remote:        Installing actionpack 4.2.4
remote:        Installing globalid 0.3.6
remote:        Installing activejob 4.2.4
remote:        Installing mime-types 2.6.2
remote:        Installing mail 2.6.3
remote:        Installing actionmailer 4.2.4
remote:        Installing activemodel 4.2.4
remote:        Installing arel 6.0.3
remote:        Installing activerecord 4.2.4
remote:        Installing coffee-script-source 1.9.1.1
remote:        Installing execjs 2.6.0
remote:        Installing coffee-script 2.4.1
remote:        Installing thor 0.19.1
remote:        Installing railties 4.2.4
remote:        Installing coffee-rails 4.1.0
remote:        Installing multi_json 1.11.2
remote:        Installing jbuilder 2.3.2
remote:        Installing jquery-rails 4.0.5
remote:        Using bundler 1.9.7
remote:        Installing sprockets 3.4.0
remote:        Installing sprockets-rails 2.3.3
remote:        Installing rails 4.2.4
remote:        Installing rdoc 4.2.0
remote:        Installing sass 3.4.19
remote:        Installing tilt 2.0.1
remote:        Installing sass-rails 5.0.4
remote:        Installing sdoc 0.4.1
remote:        Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
remote:        /tmp/build_0e499d4b3416be94496280d6a0cdf1f8/vendor/ruby-2.0.0/bin/ruby extconf.rb
remote:        checking for sqlite3.h... no
remote:        sqlite3.h is missing. Try 'port install sqlite3 +universal',
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_0e499d4b3416be94496280d6a0cdf1f8/vendor/ruby-2.0.0/bin/ruby
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}/
remote:        Gem files will remain installed in /tmp/build_0e499d4b3416be94496280d6a0cdf1f8/vendor/bundle/ruby/2.0.0/gems/sqlite3-1.3.11 for inspection.
remote:        Results logged to /tmp/build_0e499d4b3416be94496280d6a0cdf1f8/vendor/bundle/ruby/2.0.0/gems/sqlite3-1.3.11/ext/sqlite3/gem_make.out
remote:        An error occurred while installing sqlite3 (1.3.11), and Bundler cannot
remote:        continue.
remote:        Make sure that `gem install sqlite3 -v '1.3.11'` 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:        Rubygems 2.0.14 is not threadsafe, so your gems must be installed one at a time. Upgrade to Rubygems 2.1.0 or higher to enable parallel gem installation.
remote:        Installing rake 10.4.2
remote:        Installing i18n 0.7.0
remote:        Installing json 1.8.3
remote:        Installing minitest 5.8.2
remote:        Installing thread_safe 0.3.5
remote:        Installing tzinfo 1.2.2
remote:        Installing activesupport 4.2.4
remote:        Installing builder 3.2.2
remote:        Installing erubis 2.7.0
remote:        Installing mini_portile 0.6.2
remote:        Installing nokogiri 1.6.6.2
remote:        Installing rails-deprecated_sanitizer 1.0.3
remote:        Installing rails-dom-testing 1.0.7
remote:        Installing loofah 2.0.3
remote:        Installing rails-html-sanitizer 1.0.2
remote:        Installing actionview 4.2.4
remote:        Installing rack 1.6.4
remote:        Installing rack-test 0.6.3
remote:        Installing actionpack 4.2.4
remote:        Installing globalid 0.3.6
remote:        Installing activejob 4.2.4
remote:        Installing mime-types 2.6.2
remote:        Installing mail 2.6.3
remote:        Installing actionmailer 4.2.4
remote:        Installing activemodel 4.2.4
remote:        Installing arel 6.0.3
remote:        Installing activerecord 4.2.4
remote:        Installing coffee-script-source 1.9.1.1
remote:        Installing execjs 2.6.0
remote:        Installing coffee-script 2.4.1
remote:        Installing thor 0.19.1
remote:        Installing railties 4.2.4
remote:        Installing coffee-rails 4.1.0
remote:        Installing multi_json 1.11.2
remote:        Installing jbuilder 2.3.2
remote:        Installing jquery-rails 4.0.5
remote:        Using bundler 1.9.7
remote:        Installing sprockets 3.4.0
remote:        Installing sprockets-rails 2.3.3
remote:        Installing rails 4.2.4
remote:        Installing rdoc 4.2.0
remote:        Installing sass 3.4.19
remote:        Installing tilt 2.0.1
remote:        Installing sass-rails 5.0.4
remote:        Installing sdoc 0.4.1
remote:        
remote:        Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
remote:        
remote:        /tmp/build_0e499d4b3416be94496280d6a0cdf1f8/vendor/ruby-2.0.0/bin/ruby extconf.rb
remote:        checking for sqlite3.h... no
remote:        sqlite3.h is missing. Try 'port install sqlite3 +universal',
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_0e499d4b3416be94496280d6a0cdf1f8/vendor/ruby-2.0.0/bin/ruby
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}/
remote:        
remote:        
remote:        Gem files will remain installed in /tmp/build_0e499d4b3416be94496280d6a0cdf1f8/vendor/bundle/ruby/2.0.0/gems/sqlite3-1.3.11 for inspection.
remote:        Results logged to /tmp/build_0e499d4b3416be94496280d6a0cdf1f8/vendor/bundle/ruby/2.0.0/gems/sqlite3-1.3.11/ext/sqlite3/gem_make.out
remote:        An error occurred while installing sqlite3 (1.3.11), and Bundler cannot
remote:        continue.
remote:        Make sure that `gem install sqlite3 -v '1.3.11'` succeeds before bundling.
remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !     
remote:  !     Detected sqlite3 gem which is not supported on Heroku.
remote:  !     https://devcenter.heroku.com/articles/sqlite3
remote:  !
remote: 
remote:  !     Push rejected, failed to compile Ruby app
remote: 
remote: Verifying deploy...
remote: 
remote: !   Push rejected to salty-oasis-5413.
remote: 
To https://git.heroku.com/salty-oasis-5413.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/salty-oasis-5413.git'

我在一些教程中看到,当你第一次执行这个命令时,heroku 会要求你输入密码,但在我的例子中它没有。

我的宝石文件

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'
# Use sqlite3 as the database for Active Record
gem 'pg', '~> 0.18.4'
gem 'rails_12factor', '~>0.0.3'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'byebug',  '~>6.0.2'
gem 'web-console', '~> 2.0'
gem 'spring',   '~>1.4.0'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'bootstrap-sass', '~> 3.3', '>= 3.3.5.1'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# 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 'sqlite3', '1.3.11'

end

group :production do
  gem 'pg', '~> 0.18.4'
  gem 'rails_12factor', '~>0.0.3'
end
  # Access an IRB console on exception pages or by using <%= console %> in views


  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring

谢谢大家。

【问题讨论】:

  • 这看起来很严重:remote: Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension。远程:/tmp/build_0e499d4b3416be94496280d6a0cdf1f8/vendor/ruby-2.0.0/bin/ruby extconf.rb 远程:检查 sqlite3.h ... 没有远程:缺少 sqlite3.h。尝试 'port install sqlite3 +universal', remote: 'yum install sqlite-devel' 或 'apt-get install libsqlite3-dev' remote: 并检查您的共享库搜索路径(远程:您的 sqlite3 共享库所在的位置) .远程:*** extconf.rb 失败***

标签: ruby-on-rails git heroku


【解决方案1】:

问题是没有安装 sqllite 以完成安装。 所以安装 sqllite3 作为你的依赖项之一并安装它

【讨论】:

  • 我安装了 sqlite3 gem。我的电脑上安装了那个包
  • heroku 是某人的服务器,通过上述命令,您将代码推送到其他服务器。 heroku 服务器还必须安装 sqllite。所以在ruby的依赖管理文件中添加sqlite3。
  • 将 sqlite-devel 添加到您的 gem 文件中,如devcenter.heroku.com/articles/…中所述
  • 我添加了 sqlite3,似乎在我运行捆绑安装时有效。然后我尝试将它上传到heroku,但似乎没有任何效果。在 bundle install --without production 我输入了 git add 之后。 git commit -am "some text" 然后 git push heroku master
  • 据我所知,你不能在 heroku 中使用 sqlite,你必须使用 pg。所以你不应该将 sqlite 添加到你的 gem 文件中。
猜你喜欢
  • 2019-10-14
  • 1970-01-01
  • 2013-02-03
  • 2016-12-26
  • 1970-01-01
  • 1970-01-01
  • 2014-07-05
  • 1970-01-01
  • 2011-05-23
相关资源
最近更新 更多