【问题标题】:when i deploy my rails app on heroku,the step "verifying deploy.." won't stop.And finally failed to deploy当我在heroku上部署我的rails应用程序时,“验证部署..”步骤不会停止。最后未能部署
【发布时间】:2016-10-21 14:28:33
【问题描述】:

当我在 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

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

【问题讨论】:

  • 能否在您的问题中发布您的 gem 文件内容。

标签: ruby-on-rails heroku


【解决方案1】:

您正在使用 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 上到处都是。

【讨论】:

  • 当然。我希望在开发中使用 SQLite 并在生产中使用 PostgreSQL 不会给您带来麻烦。
  • 你好。其实我是第一次使用stackoverflow,你让我爱上了这个网站。
  • @jvillian:为什么不建议遵循我解决问题的方法?我的回答有什么可以改进的吗?
  • @PraveenGeorge :正如我从 Heroku 中引用的,“在生产中使用与开发中相同的数据库很重要”。您的回答技术上有效,但与 Heroku 的建议直接矛盾。
  • @jvillian:是的,我建议他在开发中使用 SQLite,在生产中使用 PostgreSQL,因为他最喜欢使用 SQLite。
【解决方案2】:

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

【讨论】:

    【解决方案3】:

    方法 1

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

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

    或者只需在 gemfile 的开头添加下面的代码。

    gem 'pg'
    

    ########################################### ##################################

    方法 2

    在开发、测试和生产环境中使用 SQLite(不推荐配置)

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

    我认为在您的 gemfile 中,您可能已经指定在生产和开发环境中使用 SQLite。这会导致 Heroku 部署出现问题,因为 Heroku 不支持在生产环境中使用 SQLite。所以你必须像下面这样修改关于你的数据库 gem 的 gemfile 部分,但我仍然提醒你在开发和生产中使用不同的数据库。

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

    如上编辑 Gemfile

    • 删除 Gemfile.lock
    • 运行 bundle install --without production
    • git 添加。
    • git commit -am "更新数据库配置"
    • git push heroku master

    【讨论】:

      猜你喜欢
      • 2016-10-10
      • 1970-01-01
      • 1970-01-01
      • 2018-08-05
      • 2014-08-08
      • 2018-06-10
      • 2017-03-25
      • 2019-10-01
      • 1970-01-01
      相关资源
      最近更新 更多