由于sqlite3 gem错误,Heroku部署失败
我刚刚开始了Michael Hartl的ruby.railstutorial.org书,并在第一章中进行了工作。我正在使用mac book OS X,Terminal和Sublime Text。一切都按照计划进行,直到有时间测试部署到Heroku。我可以连接到Heroku并运行 $ git push heroku
master命令。但是部署失败:
I just started the ruby.railstutorial.org book by Michael Hartl and have been working through the first chapter. I am using mac book OS X, Terminal, and Sublime Text. Everything has gone according to plan, up until it was time to test deployment to Heroku. I am able to connect to Heroku and run the $ git push heroku
master command. But the deployment fails:
Installing sqlite3 (1.3.5) with native extensions
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:
An error occurred while installing sqlite3 (1.3.5), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.5'` succeeds before bundling.
!
! Failed to install gems via Bundler.
!
! Detected sqlite3 gem which is not supported on Heroku.
! http://devcenter.heroku.com/articles/how-do-i-use-sqlite3-for-development
!
! Heroku push rejected, failed to compile Ruby/rails app
这是我的Gemfile
Here is my Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.8'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :development, :test do
gem 'sqlite3', '1.3.5'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.5'
gem 'coffee-rails', '~> 3.2.2'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.2.3'
end
gem 'jquery-rails', '2.0.2'
group :production do
gem 'pg', '0.12.2'
end
# 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 'debugger'
我有sqlite3指定用于开发而不是生产,所以我认为Heroku会一起忽略它,但似乎没有这样的情况。
I have sqlite3 designated for development and not production, so I thought Heroku would just ignore it all together, but that does not seem to be the case.
此外,当我创建捆绑包时,我使用
$ bundle install - 无需生产
Also, when i create the bundle i am using $ bundle install --without production
我知道有些人建议安装PG并使用它,但是我真的想在尽可能多的时候坚持使用教程,然后再尝试其他方法。
I know that some people has suggested to just install PG and use that, but I really want to stick to the tutorial as much as possible, before I venture out and try a different approach.
我现在有点迷失,不知道如何从这里开始。任何您可以提供的帮助将是非常感谢。
I am a bit lost at the moment, and not sure how to proceed from here. Any help that you can provide would be most appreciated.
谢谢
Heroku无法安装sqlite3 gem,无论什么原因但是您可以告诉 bundler
,除非在开发过程中不要尝试。
Heroku can't install the sqlite3 gem, for whatever reason. But you can tell bundler
that it shouldn't be trying to except when developing.
在 Gemfile
中,替换 gem'sqlite3'
with:
In your Gemfile
, replace gem 'sqlite3'
with:
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
然后bundler on heroku ,以生产
运行,不会尝试安装。
Then bundler on heroku, running as production
, won't try to install it.