当我在heroku上部署我的rails应用程序时,“验证部署...”的步骤将不会停止。最终无法部署

时间:2016-02-29 02:30:45

标签: ruby-on-rails heroku

当我在heroku上部署我的rails应用程序时,“验证部署...”的步骤将不会停止。最终无法部署。 看起来像: .....

Counting objects: 63, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (50/50), done.
Writing objects: 100% (63/63), 16.07 KiB | 0 bytes/s, done.
Total 63 (delta 2), reused 55 (delta 2)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.2.4
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://ruby.taobao.org/...........
remote:        Fetching version metadata from https://ruby.taobao.org/..
remote:        Installing i18n 0.7.0
.
.
.
.
remote:        Installing rack-test 0.6.3
remote:        Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
remote:        /tmp/build_79f9308360752d0592fbc2b468f9b84c/vendor/ruby-2.2.4/bin/ruby -r ./siteconf20160229-317-1hewtf6.rb 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_79f9308360752d0592fbc2b468f9b84c/vendor/ruby-2.2.4/bin/$(RUBY_BASE_NAME)
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:        extconf failed, exit code 1
remote:        Gem files will remain installed in /tmp/build_79f9308360752d0592fbc2b468f9b84c/vendor/bundle/ruby/2.2.0/gems/sqlite3-1.3.11 for inspection.
remote:        Results logged to /tmp/build_79f9308360752d0592fbc2b468f9b84c/vendor/bundle/ruby/2.2.0/extensions/x86_64-linux/2.2.0-static/sqlite3-1.3.11/gem_make.out
remote:        Installing uglifier 2.7.2
remote:        Installing rdoc 4.2.2
remote:        Installing sprockets 3.5.2
remote:        Installing coffee-script 2.4.1
remote:        Installing mail 2.6.3
remote:        Installing activesupport 4.2.5.1
remote: Verifying deploy...............................................................................................................................................................................................................................................................................................................................................................................................................................................
error: RPC failed; result=18, HTTP code = 200
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
Everything up-to-date

“验证部署”这一步花了我很长时间,最后失败了。 我该怎么办?

3 个答案:

答案 0 :(得分:4)

您正在使用SQLite,如下所示:

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).

Heroku不支持SQLite,如here所述。链接的文章还指出:

  

在开发中使用与生产中相同的数据库非常重要,因此您需要在本地安装PostgreSQL数据库。

如果要在Heroku上部署,则需要切换到PostgreSQL。我不建议您遵循Praveen George的建议。 SQLite允许PostgreSQL没有的东西。因此,在开发过程中,您可能会认为一切都很好,只是发现它在Heroku上遍布各处。

答案 1 :(得分:0)

Heroku部署步骤

heroku login
heroku create

git remote -v

heroku git:remote -a app_name(which u get when u do 3rd step)

git push heroku master

确保你的Gemfile有

gem 'pg'
group :production do
gem 'rails_12factor'
end

重置数据库

heroku pg:reset DATABASE_URL

heroku run rake db:migrate db:seed

重命名Heroku应用程序

heroku apps:rename newname --app oldname

如果资产没有加载

rake assets:precompile
git add
git commit
git push

答案 2 :(得分:-1)

<方法1

在开发,测试和使用中使用PSQL生产(推荐配置)

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

或者只需在宝石文件的开头添加波纹管代码即可。

gem 'pg'

<强> ############################################ ###################################

<方法2

在开发,测试和使用中使用SQLite生产中的PSQL(不推荐配置)

重要提示: 不要这样做。你将在未来遇到问题。在生产和开发中使用相同的数据库。 For more details see this Stackoverflow post

我认为在你的gemfile中,你可能已经指定在生产和开发环境中使用SQLite。这导致Heroku部署中的问题,因为Heroku不支持在生产中使用SQLite。所以你必须修改你的宝石文件部分关于你的数据库宝石,如下所示,但我仍然提醒你在开发和生产中使用不同的数据库不建议。

gem 'sqlite3', :group => [:development, :test]
group :production do
  gem 'thin'
  gem 'pg'
end

按上述方式编辑Gemfile

  • 删除Gemfile.lock
  • 运行捆绑安装 - 无需生产
  • git add。
  • git commit -am“更新数据库配置”
  • git push heroku master