我试图在heroku上发布我的演示应用程序(来自ruby教程),但我遇到错误的git push heroku master
实现错误:
Counting objects: 129, done.
Compressing objects: 100% (114/114), done.
Writing objects: 100% (129/129), 119.95 KiB | 0 bytes/s, done.
Total 129 (delta 19), 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 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/.. [173/194]
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.7.0
remote: Installing thread_safe 0.3.5
remote: Installing tzinfo 1.2.2
remote: Installing activesupport 4.2.3
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.6
remote: Installing loofah 2.0.2
remote: Installing rails-html-sanitizer 1.0.2
remote: Installing actionview 4.2.3
remote: Installing rack 1.6.4
remote: Installing rack-test 0.6.3
remote: Installing actionpack 4.2.3
remote: Installing globalid 0.3.5
remote: Installing activejob 4.2.3
remote: Installing mime-types 2.6.1
remote: Installing mail 2.6.3
remote: Installing actionmailer 4.2.3
remote: Installing activemodel 4.2.3
remote: Installing arel 6.0.0
remote: Installing activerecord 4.2.3
remote: Installing coffee-script-source 1.9.1.1
remote: Installing execjs 2.5.2
remote: Installing coffee-script 2.4.1
remote: Installing thor 0.19.1
remote: Installing railties 4.2.3
remote: Installing coffee-rails 4.1.0
remote: Installing multi_json 1.11.2
remote: Installing jbuilder 2.3.1
remote: Installing jquery-rails 4.0.4
remote: Installing pg 0.18.2
remote: Using bundler 1.9.7
remote: Installing sprockets 3.2.0
remote: Installing sprockets-rails 2.3.2
remote: Installing rails 4.2.3
remote: Installing rails_serve_static_assets 0.0.4
remote: Installing rails_stdout_logging 0.0.3
remote: Installing rails_12factor 0.0.2
remote: Installing rdoc 4.2.0
remote: Installing sass 3.4.15
remote: Installing tilt 1.4.1
remote: Installing sass-rails 5.0.3
remote: Installing sdoc 0.4.1
remote: Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
remote: /tmp/build_32f45e65619752c6e5c6598bfc3ced31/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_32f45e65619752c6e5c6598bfc3ced31/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_32f45e65619752c6e5c6598bfc3ced31/vendor/bundle/ruby/2.0.0/gems/sqlite3-1.3.10 for inspection.
remote: Results logged to /tmp/build_32f45e65619752c6e5c6598bfc3ced31/vendor/bundle/ruby/2.0.0/gems/sqlite3-1.3.10/ext/sqlite3/gem_make.out
remote: An error occurred while installing sqlite3 (1.3.10), and Bundler cannot
remote: continue.
remote: Make sure that `gem install sqlite3 -v '1.3.10'` 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.7.0
remote: Installing thread_safe 0.3.5
remote: Installing tzinfo 1.2.2
remote: Installing activesupport 4.2.3
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.6
remote: Installing loofah 2.0.2
remote: Installing rails-html-sanitizer 1.0.2
remote: Installing actionview 4.2.3
remote: Installing rack 1.6.4
remote: Installing rack-test 0.6.3
remote: Installing actionpack 4.2.3
remote: Installing globalid 0.3.5
remote: Installing activejob 4.2.3
remote: Installing mime-types 2.6.1
remote: Installing mail 2.6.3
remote: Installing actionmailer 4.2.3
remote: Installing activemodel 4.2.3
remote: Installing arel 6.0.0
remote: Installing activerecord 4.2.3
remote: Installing execjs 2.5.2 [56/194]
remote: Installing coffee-script 2.4.1
remote: Installing thor 0.19.1
remote: Installing railties 4.2.3
remote: Installing coffee-rails 4.1.0
remote: Installing multi_json 1.11.2
remote: Installing jbuilder 2.3.1
remote: Installing jquery-rails 4.0.4
remote: Installing pg 0.18.2
remote: Using bundler 1.9.7
remote: Installing sprockets 3.2.0
remote: Installing sprockets-rails 2.3.2
remote: Installing rails 4.2.3
remote: Installing rails_serve_static_assets 0.0.4
remote: Installing rails_stdout_logging 0.0.3
remote: Installing rails_12factor 0.0.2
remote: Installing rdoc 4.2.0
remote: Installing sass 3.4.15
remote: Installing tilt 1.4.1
remote: Installing sass-rails 5.0.3
remote: Installing sdoc 0.4.1
remote:
remote: Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
remote:
remote: /tmp/build_32f45e65619752c6e5c6598bfc3ced31/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_32f45e65619752c6e5c6598bfc3ced31/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_32f45e65619752c6e5c6598bfc3ced31/vendor/bundle/ruby/2.0.0/gems/sqlite3-1.3.10 for inspection.
remote: Results logged to /tmp/build_32f45e65619752c6e5c6598bfc3ced31/vendor/bundle/ruby/2.0.0/gems/sqlite3-1.3.10/ext/sqlite3/gem_make.out
remote: An error occurred while installing sqlite3 (1.3.10), and Bundler cannot
remote: continue.
remote: Make sure that `gem install sqlite3 -v '1.3.10'` 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 hopehope.
remote:
To https://git.heroku.com/hopehope.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/hopehope.git'
azureuser@host:~/railstutorial_apps/demo$
(此外,应用程序在azure虚拟机上启动,没有任何错误) 我已经尝试单独安装sqllite(成功),但即使安装了sqllite后我也有同样的错误:(
Gemfile中的sqlite3 gem:
gem 'sqlite3', '1.3.10'
答案 0 :(得分:3)
在你的gemfile中添加gem' pg'作为生产组,因为heroku支持postgresql
group :development do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
并添加adapter: postgresql
您的database.yml
production:
adapter: postgresql
encoding: unicode
database: database_name_production
答案 1 :(得分:2)
Heroku不支持sqlite3,因此它不会有安装sqlite3 gem所需的库文件。
您需要将sqlite3添加到Gemfile中的开发块,以便在部署期间不会安装它。
group :development do
gem 'sqlite3'
end
另外,请注意使用postgresql确保应用程序按预期运行。就个人而言,我建议使用相同类型的数据库进行开发,以便在将应用程序转移到生产环境时不会有任何意外。