ruby-on-rails - 使用sqlite3进行开发的Rails应用程序不会部署到heroku中

标签 ruby-on-rails git heroku sqlite

我正在尝试部署使用SQLite3创建的Rails应用程序。但是在运行git push heroku master之后,我不断收到以下错误

Initializing repository, done.
Counting objects: 164, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (147/147), done.
Writing objects: 100% (164/164), 78.88 KiB | 0 bytes/s, done.
Total 164 (delta 33), reused 0 (delta 0)

-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using 1.6.3
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
       Fetching gem metadata from https://rubygems.org/.........
       Fetching additional metadata from https://rubygems.org/..
       Installing rake 10.3.2
       Installing i18n 0.6.9
       Installing minitest 5.3.5
       Installing thread_safe 0.3.4
       Installing builder 3.2.2
       Installing erubis 2.7.0
       Installing rack 1.5.2
       Installing mime-types 1.25.1
       Installing polyglot 0.3.5
       Installing json 1.8.1
       Installing arel 5.0.1.20140414130214
       Installing coffee-script-source 1.7.0
       Installing execjs 2.2.0
       Installing thor 0.19.1
       Using bundler 1.6.3
       Installing hike 1.2.3
       Installing multi_json 1.10.1
       Installing sass 3.2.19
       Installing tilt 1.4.1
       Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
       /tmp/build_c9d45d78-4c2b-4825-9bd8-b3961ccc175f/vendor/ruby-2.0.0/bin/ruby extconf.rb
       checking for sqlite3.h... no
       sqlite3.h is missing. Try 'port install sqlite3 +universal',
       'yum install sqlite-devel' or 'apt-get install libsqlite3-dev'
       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=/tmp/build_c9d45d78-4c2b-4825-9bd8-b3961ccc175f/vendor/ruby-2.0.0/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}/
       --enable-local
       --disable-local
       Gem files will remain installed in /tmp/build_c9d45d78-4c2b-4825-9bd8-b3961ccc175f/vendor/bundle/ruby/2.0.0/gems/sqlite3-1.3.9 for inspection.
       Results logged to /tmp/build_c9d45d78-4c2b-4825-9bd8-b3961ccc175f/vendor/bundle/ruby/2.0.0/gems/sqlite3-1.3.9/ext/sqlite3/gem_make.out
       Installing rack-test 0.6.2
       Installing tzinfo 1.2.1
       An error occurred while installing sqlite3 (1.3.9), and Bundler cannot continue.
       Make sure that `gem install sqlite3 -v '1.3.9'` succeeds before bundling.
       Bundler Output: Fetching gem metadata from https://rubygems.org/.........
       Fetching additional metadata from https://rubygems.org/..
       Installing rake 10.3.2
       Installing i18n 0.6.9
       Installing minitest 5.3.5
       Installing thread_safe 0.3.4
       Installing builder 3.2.2
       Installing erubis 2.7.0
       Installing rack 1.5.2
       Installing mime-types 1.25.1
       Installing polyglot 0.3.5
       Installing json 1.8.1
       Installing arel 5.0.1.20140414130214
       Installing coffee-script-source 1.7.0
       Installing execjs 2.2.0
       Installing thor 0.19.1
       Using bundler 1.6.3
       Installing hike 1.2.3
       Installing multi_json 1.10.1
       Installing sass 3.2.19
       Installing tilt 1.4.1

       Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

       /tmp/build_c9d45d78-4c2b-4825-9bd8-b3961ccc175f/vendor/ruby-2.0.0/bin/ruby extconf.rb
       checking for sqlite3.h... no
       sqlite3.h is missing. Try 'port install sqlite3 +universal',
       'yum install sqlite-devel' or 'apt-get install libsqlite3-dev'
       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=/tmp/build_c9d45d78-4c2b-4825-9bd8-b3961ccc175f/vendor/ruby-2.0.0/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}/
       --enable-local
       --disable-local


       Gem files will remain installed in /tmp/build_c9d45d78-4c2b-4825-9bd8-b3961ccc175f/vendor/bundle/ruby/2.0.0/gems/sqlite3-1.3.9 for inspection.
       Results logged to /tmp/build_c9d45d78-4c2b-4825-9bd8-b3961ccc175f/vendor/bundle/ruby/2.0.0/gems/sqlite3-1.3.9/ext/sqlite3/gem_make.out
       Installing rack-test 0.6.2
       Installing tzinfo 1.2.1
       An error occurred while installing sqlite3 (1.3.9), and Bundler cannot continue.
       Make sure that `gem install sqlite3 -v '1.3.9'` succeeds before bundling.
 !
 !     Failed to install gems via Bundler.
 !     
 !     Detected sqlite3 gem which is not supported on Heroku.
 !     https://devcenter.heroku.com/articles/sqlite3
 !

 !     Push rejected, failed to compile Ruby app

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


这是我的gemfile:

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.1'
# Use sqlite3 as the database for Active Record
group :development do
  gem 'sqlite3', '1.3.8'
  gem 'spring'
end
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer',  platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0',          group: :doc

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


我毫无问题地部署了Michael Hartl的“ Rails教程”中出现的所有应用程序,但是现在我正在使用更新版本的rails和ruby开发自己的应用程序,对此我遇到了麻烦。任何帮助将不胜感激。

最佳答案

数据

Heroku doesn't support SQLite3,因为它将数据存储在硬盘驱动器上(在新的推送中将被覆盖)。

持久性数据存储(数据库)是必需的,并且Heroku recommend Postgres

-

错误

我认为您的错误将有几种潜在原因:



您尚未更新Gemfile.lock文件
在提交给Heroku之前,您尚未正确提交Gemfile
您的gems之一依赖于sqlite3(不太可能)



我将解决这样的问题:

#Gemfile
group :development do
   #gem 'sqlite' -> comment out for now
end

group :production do
   gem 'pg'
end


然后,我将确保已完成所有更改:

$ git add .
$ git commit -a -m "Heroku"
$ git push heroku master


这将使您可以将Gemfile的真实版本推送到Heroku,从而使您可以正确测试部署

如果您需要任何进一步的帮助,请发表评论,我会帮助您!

关于ruby-on-rails - 使用sqlite3进行开发的Rails应用程序不会部署到heroku中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24443891/

相关文章:

ruby-on-rails - 请求 Rails 应用程序显着增加内存

ruby-on-rails - 在 Rails 中创建 Action

git - 我可以通过将符号链接(symbolic link)放入 git 存储库来添加文件吗?

python - Heroku 上的 Django 和 Postgresql - 无法将主机名 "db"转换为地址 : Name or service not known

heroku - 在Heroku上托管Dart应用程序的问题

ruby - Sidekiq 作业在 Heroku 上排在队列中

ruby-on-rails - id字段的Elasticsearch构面值

ruby-on-rails - Rails — 带有 "dot"的参数(例如/google.com)

git - Git rebase 使用什么算法?

javascript - 将 git 分支列表存储在变量中