xua*_*mox 17 sqlite deployment gem ruby-on-rails heroku
我刚刚开始阅读Michael Hartl撰写的ruby.railstutorial.org一书,并一直在完成第一章.我正在使用mac book OS X,Terminal和Sublime Text.一切都按计划进行,直到测试部署到Heroku为止.我能够连接到Heroku并运行$ git push herokumaster命令.但是部署失败了:
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
Run Code Online (Sandbox Code Playgroud)
这是我的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'
Run Code Online (Sandbox Code Playgroud)
我有sqlite3指定用于开发而不是生产,所以我认为Heroku会一起忽略它,但似乎并非如此.
此外,当我创建捆绑我使用$ bundle install --without production
我知道有些人建议只安装PG并使用它,但我真的想尽可能地坚持本教程,然后再冒险尝试不同的方法.
我此刻有点失落,不知道如何从这里开始.您可以提供的任何帮助将非常感激.
谢谢
Cho*_*ett 23
无论出于何种原因,Heroku都无法安装sqlite3 gem.但你可以说bundler,除了开发之外它不应该尝试.
在你的Gemfile,替换gem 'sqlite3'为:
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
Run Code Online (Sandbox Code Playgroud)
然后运行的heroku上的bundler production将不会尝试安装它.
xua*_*mox 14
我终于能够成功部署到Heroku.感谢evanc3指向我在Heroku网站上的一篇文章.在部署到Heroku之前,我似乎忘了提交我的Gemgile更新.因此,对于刚刚开始的所有人,您需要确保在部署到Heroku之前提交更改.
Heroku不支持sqlite3 ...
从您的Gemfile中删除sqlite3,改为使用pg gem.在gem文件中进行以下更改
改变你的追随者 Gemfile
gem 'sqlite3'
Run Code Online (Sandbox Code Playgroud)
至
gem 'pg' #you will have to install postgresql
Run Code Online (Sandbox Code Playgroud)
重要:跑
git add .
git commit
git push heroku master
Run Code Online (Sandbox Code Playgroud)
注意:如果您计划部署heroku,我建议最好在开发阶段使用postgres(在您的计算机上安装postgresql),heroku更喜欢psql.
如果要使用sqllite进行开发,使用postgresql进行Heroku,请使用以下配置.
group :development do
gem 'sqlite3' #gem to use in development environment
end
group :production do
gem 'pg' #gem to use in production environment
end
Run Code Online (Sandbox Code Playgroud)
Heroku将使用pggem,因为heroku在生产环境中运行您的应用程序
| 归档时间: |
|
| 查看次数: |
15346 次 |
| 最近记录: |