1

我是 RoR 的初学者,我正在尝试将我的第一个应用程序部署到 Heroku。我们正在使用 GitHub 作为存储库,并在尝试部署时不断收到错误:“git push heroku master”

请参阅下面我们运行时收到的消息。

$ git push heroku master
Warning: Permanently added the RSA host key for IP address '50.19.85.156' to the list of       known hosts.
Counting objects: 69, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (55/55), done.
Writing objects: 100% (69/69), 26.38 KiB, done.
Total 69 (delta 5), reused 0 (delta 0)
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.3.0.pre.5
   Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
   Fetching gem metadata from https://rubygems.org/.........
   Fetching gem metadata from https://rubygems.org/..
   Installing rake (10.0.3)
   Installing i18n (0.6.1)
   Installing multi_json (1.6.0)
   Installing activesupport (3.2.11)
   Installing builder (3.0.4)
   Installing activemodel (3.2.11)
   Installing erubis (2.7.0)
   Installing journey (1.0.4)
   Installing rack (1.4.5)
   Installing rack-cache (1.2)
   Installing rack-test (0.6.2)
   Installing hike (1.2.1)
   Installing tilt (1.3.3)
   Installing sprockets (2.2.2)
   Installing actionpack (3.2.11)
   Installing mime-types (1.21)
   Installing polyglot (0.3.3)
   Installing treetop (1.4.12)
   Installing mail (2.4.4)
   Installing actionmailer (3.2.11)
   Installing arel (3.0.2)
   Installing tzinfo (0.3.35)
   Installing activerecord (3.2.11)
   Installing activeresource (3.2.11)
   Installing coffee-script-source (1.4.0)
   Installing execjs (1.4.0)
   Installing coffee-script (2.2.0)
   Installing rack-ssl (1.3.3)
   Installing json (1.7.7)
   Installing rdoc (3.12.1)
   Installing thor (0.17.0)
   Installing railties (3.2.11)
   Installing coffee-rails (3.2.2)
   Installing jquery-rails (2.2.1)
   Using bundler (1.3.0.pre.5)
   Installing rails (3.2.11)
   Installing sass (3.2.5)
   Installing sass-rails (3.2.6)
   Installing sqlite3 (1.3.7)
   Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
   /usr/local/bin/ruby extconf.rb
   checking for sqlite3.h... no
   sqlite3.h is missing. Try 'port install sqlite3 +universal'
   or 'yum install sqlite-devel' and check your shared library search path (the
   location where your sqlite3 shared library is located).
   *** extconf.rb failed ***
   Could not create Makefile due to some reason, probably lack of
   necessary libraries and/or headers.  Check the mkmf.log file for more
   details.  You may need configuration options.
   Provided configuration options:
   --with-opt-dir
   --without-opt-dir
   --with-opt-include
   --without-opt-include=${opt-dir}/include
   --with-opt-lib
   --without-opt-lib=${opt-dir}/lib
   --with-make-prog
   --without-make-prog
   --srcdir=.
   --curdir
   --ruby=/usr/local/bin/ruby
   --with-sqlite3-dir
   --without-sqlite3-dir
   --with-sqlite3-include
   --without-sqlite3-include=${sqlite3-dir}/include
   --with-sqlite3-lib
   --without-sqlite3-lib=${sqlite3-dir}/lib
   --enable-local
   --disable-local
   Gem files will remain installed in  /tmp/build_1um81jm55kdnc/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.7 for inspection.
   Results logged to /tmp/build_1um81jm55kdnc/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.7/ext/sqlite3/gem_make.out
   An error occurred while installing sqlite3 (1.3.7), and Bundler cannot continue.
   Make sure that `gem install sqlite3 -v '1.3.7'` succeeds before bundling.
   !
   !     Failed to install gems via Bundler.
   !
   !     Heroku push rejected, failed to compile Ruby/rails app

   To git@heroku.com:aqueous-tor-8402.git
   ! [remote rejected] master -> master (pre-receive hook declined)
   error: failed to push some refs to 'git@heroku.com:aqueous-tor-8402.git'

我的宝石文件如下:

source 'https://rubygems.org'

gem 'rails', '3.2.11'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'

gem 'json'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails',   '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby

 gem 'uglifier', '>= 1.0.3'
 end

 gem 'jquery-rails'

 # To use ActiveModel has_secure_password
 # gem 'bcrypt-ruby', '~> 3.0.0'

 # To use Jbuilder templates for JSON
 # gem 'jbuilder'

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

 # Deploy with Capistrano
 # gem 'capistrano'

 # To use debugger
 # gem 'ruby-debug'

当我运行“sqlite3 -version”时,我得到:

 3.7.12 2012-04-03 19:43:07 86b8481be7e76cccc92d14ce762d21bfb69504af

当我执行“捆绑显示 sqlite3”时,我得到:

 /Library/Ruby/Gems/1.8/gems/sqlite3-1.3.7

抱歉,这是我的第一个 Rails 应用程序,所以我对这些东西比较陌生。

任何帮助,将不胜感激。

更新:这是 Heroku 日志

$ heroku logs
2013-02-12T22:04:25+00:00 heroku[api]: Enable Logplex by peterbarbosa1@gmail.com
2013-02-12T22:04:25+00:00 heroku[api]: Release v2 created by peterbarbosa1@gmail.com
2013-02-12T22:04:47+00:00 heroku[router]: at=info code= desc="Blank app" method=GET         path=/favicon.ico host=aqueous-tor-8402.herokuapp.com fwd=99.250.119.144 dyno= queue= wait=             connect= service= status=502 bytes=
2013-02-12T22:04:46+00:00 heroku[router]: at=info code= desc="Blank app" method=GET path=/ host=aqueous-tor-8402.herokuapp.com fwd=99.250.119.144 dyno= queue= wait= connect= service= status=502 bytes=
2013-02-12T22:41:52+00:00 heroku[slugc]: Slug compilation started
2013-02-12T22:42:39+00:00 heroku[slugc]: Slug compilation failed: failed to compile Ruby/rails app
2013-02-12T22:45:56+00:00 heroku[slugc]: Slug compilation started
2013-02-12T22:46:30+00:00 heroku[slugc]: Slug compilation failed: failed to compile Ruby/rails app
2013-02-12T22:59:31+00:00 heroku[slugc]: Slug compilation started
2013-02-12T22:59:52+00:00 heroku[slugc]: Slug compilation failed: failed to compile Ruby/rails app
2013-02-12T23:00:39+00:00 heroku[router]: at=info code= desc="Blank app" method=GET path=/ host=aqueous-tor-8402.herokuapp.com fwd=99.250.119.144 dyno= queue= wait= connect= service= status=502 bytes=
2013-02-12T23:00:39+00:00 heroku[router]: at=info code= desc="Blank app" method=GET path=/favicon.ico host=aqueous-tor-8402.herokuapp.com fwd=99.250.119.144 dyno= queue= wait= connect= service= status=502 bytes=
2013-02-12T23:08:25+00:00 heroku[slugc]: Slug compilation started
2013-02-12T23:08:50+00:00 heroku[slugc]: Slug compilation failed: failed to compile Ruby/rails app
2013-02-12T23:13:09+00:00 heroku[slugc]: Slug compilation started
2013-02-12T23:13:45+00:00 heroku[slugc]: Slug compilation failed: failed to compile Ruby/rails app
2013-02-12T23:18:14+00:00 heroku[slugc]: Slug compilation started
2013-02-12T23:18:41+00:00 heroku[slugc]: Slug compilation failed: failed to compile Ruby/rails app
2013-02-12T23:20:03+00:00 heroku[slugc]: Slug compilation started
2013-02-12T23:20:34+00:00 heroku[slugc]: Slug compilation failed: failed to compile Ruby/rails app
2013-02-12T23:22:39+00:00 heroku[slugc]: Slug compilation started
2013-02-12T23:23:05+00:00 heroku[slugc]: Slug compilation failed: failed to compile Ruby/rails app
2013-02-12T23:25:50+00:00 heroku[slugc]: Slug compilation started
2013-02-12T23:26:37+00:00 heroku[slugc]: Slug compilation failed: failed to compile Ruby/rails app
2013-02-12T23:28:52+00:00 heroku[slugc]: Slug compilation started
2013-02-12T23:29:20+00:00 heroku[slugc]: Slug compilation failed: failed to compile Ruby/rails app
2013-02-12T23:31:20+00:00 heroku[slugc]: Slug compilation started
2013-02-12T23:32:01+00:00 heroku[slugc]: Slug compilation failed: failed to compile Ruby/rails app
2013-02-12T23:42:41+00:00 heroku[slugc]: Slug compilation started
2013-02-12T23:43:08+00:00 heroku[slugc]: Slug compilation failed: failed to compile Ruby/rails app
2013-02-12T23:48:22+00:00 heroku[slugc]: Slug compilation started
2013-02-12T23:48:47+00:00 heroku[slugc]: Slug compilation failed: failed to compile Ruby/rails app
2013-02-12T23:52:52+00:00 heroku[slugc]: Slug compilation started
2013-02-12T23:53:16+00:00 heroku[slugc]: Slug compilation failed: failed to compile     Ruby/rails app
2013-02-13T00:08:04+00:00 heroku[router]: at=info code= desc="Blank app" method=GET path=/ host=aqueous-tor-8402.herokuapp.com fwd=99.250.119.144 dyno= queue= wait= connect= service= status=502 bytes=
2013-02-13T00:08:04+00:00 heroku[router]: at=info code= desc="Blank app" method=GET path=/favicon.ico host=aqueous-tor-8402.herokuapp.com fwd=99.250.119.144 dyno= queue= wait= connect= service= status=502 bytes=
2013-02-13T00:09:49+00:00 heroku[router]: at=info code= desc="Blank app" method=GET path=/ host=pbarbosa.herokuapp.com fwd=99.250.119.144 dyno= queue= wait= connect= service= status=502 bytes=
2013-02-13T00:09:49+00:00 heroku[router]: at=info code= desc="Blank app" method=GET path=/favicon.ico host=pbarbosa.herokuapp.com fwd=99.250.119.144 dyno= queue= wait= connect= service= status=502 bytes=
2013-02-13T00:09:49+00:00 heroku[router]: at=info code=H16 desc="herokuapp redirect" method=GET path=/ host=pbarbosa.heroku.com fwd="99.250.119.144" dyno= queue= wait= connect= service= status=301 bytes=
2013-02-13T00:19:18+00:00 heroku[slugc]: Slug compilation started
2013-02-13T00:19:41+00:00 heroku[slugc]: Slug compilation failed: failed to compile Ruby/rails app
2013-02-13T00:39:17+00:00 heroku[api]: Attach HEROKU_POSTGRESQL_AQUA resource by peterbarbosa1@gmail.com
2013-02-13T00:39:17+00:00 heroku[api]: Release v3 created by peterbarbosa1@gmail.com
2013-02-13T01:27:38+00:00 heroku[slugc]: Slug compilation started
2013-02-13T01:27:59+00:00 heroku[slugc]: Slug compilation failed: failed to compile Ruby/rails app
2013-02-13T01:29:28+00:00 heroku[slugc]: Slug compilation started
2013-02-13T01:29:52+00:00 heroku[slugc]: Slug compilation failed: failed to compile Ruby/rails app
2013-02-13T01:31:32+00:00 heroku[slugc]: Slug compilation started
2013-02-13T01:32:01+00:00 heroku[slugc]: Slug compilation failed: failed to compile Ruby/rails app
2013-02-13T01:32:30+00:00 heroku[slugc]: Slug compilation started
2013-02-13T01:32:55+00:00 heroku[slugc]: Slug compilation failed: failed to compile Ruby/rails app
4

2 回答 2

7

Heroku 不支持 sqlite 数据库。您需要在生产中使用postgres。在 Rails 中,切换数据库很容易:

group :production do
  gem "pg"
end

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

像上面一样更改您的 gemfile,然后运行bundle​​并将您的更改提交到Gemfileand Gemfile.lock。然后,git push heroku master再次运行。

这将允许您在开发和测试环境中本地使用 sqlite,并根据需要在 heroku 上使用 postgres。

顺便说一句,rails 的主要优点之一是它可以让您轻松切换数据库。在其他框架中,这样做可能会花费您数小时。

于 2013-02-13T00:14:53.117 回答
0

这里有几件事要确保

  1. 在 database.yml 上注释掉生产环境。heroku 已经为您做到了。就像上面所说的那样,heroku 不使用 sqlite3,但您可以使用 sqlite3 进行测试和开发,这没有什么区别
  2. 如果您对数据库进行了任何更改,请确保在推送之前迁移您的数据库。执行 heroku 运行 rake db:migrate 然后尝试 git push heroku master。

希望这能解决它

以供将来参考,发布heroku日志,通过查看更容易解决。

于 2013-02-13T01:13:53.200 回答