推送到 heroku 失败! (Michael Hartle Rails 教程 3 - 示例应用程序)

Failure to push to heroku! (Micharl Hartle Rails Tutorial 3 - Sample App)

注意:绝对初学者。我注意到大多数类似问题的答案都指出 SQlite3 不适用于 Heroku,并建议使用 PostgreSQL。在朝那个方向做出任何改变之前,我想知道这样做是否会影响我 follow/understand 教程的能力?

我正在使用作者提供的最新 gem 文件。它于 2015 年 11 月 25 日更新。(这就是为什么我很惊讶它包含 SQlite3 gem?)

我是一个绝对的初学者,2 天前才开始学习编程。(解释和解决方案将不胜感激。(使用尽可能简化的语言)谢谢!

OS: Windows 8.1 IDE:云9 将 git 推送到 Bitbucket 帐户。

捆绑安装——没有生产,成功。 Git 初始化和进一步更新都没有错误。

source 'https://rubygems.org'

gem 'rails',                   '4.2.2'
gem 'bcrypt',                  '3.1.7'
gem 'faker',                   '1.4.2'
gem 'carrierwave',             '0.10.0'
gem 'mini_magick',             '3.8.0'
gem 'fog',                     '1.36.0'
gem 'will_paginate',           '3.0.7'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'bootstrap-sass',          '3.2.0.0'
gem 'sass-rails',              '5.0.2'
gem 'uglifier',                '2.5.3'
gem 'coffee-rails',            '4.1.0'
gem 'jquery-rails',            '4.0.3'
gem 'turbolinks',              '2.3.0'
gem 'jbuilder',                '2.2.3'
gem 'sdoc',                    '0.4.0', group: :doc

group :development, :test do
  gem 'sqlite3',     '1.3.9'
  gem 'byebug',      '3.4.0'
  gem 'web-console', '2.0.0.beta3'
  gem 'spring',      '1.1.3'
end

group :test do
  gem 'minitest-reporters', '1.0.5'
  gem 'mini_backtrace',     '0.1.3'
  gem 'guard-minitest',     '2.3.1'
end

group :production do
  gem 'pg',             '0.17.1'
  gem 'rails_12factor', '0.0.2'
  gem 'puma',           '2.11.1'
end

这是在失败的 'git push heroku master' 命令结束时出现的错误消息

remote:        Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
remote:        
remote:        /tmp/build_1933bfd027d23ded5c4a036825ecff71/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_1933bfd027d23ded5c4a036825ecff71/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_1933bfd027d23ded5c4a036825ecff71/vendor/bundle/ruby/2.0.0/gems/sqlite3-1.3.11 for inspection.
remote:        Results logged to /tmp/build_1933bfd027d23ded5c4a036825ecff71/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.

如果 SQlite3 gem 在省略的生产组中,就像前面练习中的情况一样,为什么只在本练习中发生这种情况?

Heroku 不支持SQLite,你需要切换到PG。使用 PG 不会影响您学习本教程的能力,因为 ActiveRecord 抽象了 low-level database-specific 命令。

您只需要确保您没有依赖 SQLite 特有的任何功能或行为。