由于 sqlite3 gem 错误,Heroku 部署失败

Heroku deployment failed because of sqlite3 gem error(由于 sqlite3 gem 错误,Heroku 部署失败)
本文介绍了由于 sqlite3 gem 错误,Heroku 部署失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始阅读 Michael Hartl 所著的 ruby​​.railstutorial.org 一书,并且一直在阅读第一章.我使用的是 mac book OS X、终端和 Sublime Text.一切都按计划进行,直到测试部署到 Heroku 的时候.我能够连接到 Heroku 并运行 $ git push heroku 主命令.但是部署失败:

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 --without production

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' 替换为:

In your Gemfile, replace gem 'sqlite3' with:

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

然后在 heroku 上以 production 运行的 bundler 不会尝试安装它.

Then bundler on heroku, running as production, won't try to install it.

这篇关于由于 sqlite3 gem 错误,Heroku 部署失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

FastAPI + Tortoise ORM + FastAPI Users (Python) - Relationship - Many To Many(FastAPI+Tortoise ORM+FastAPI用户(Python)-关系-多对多)
How can I generate an entity–relationship (ER) diagram of a database using Microsoft SQL Server Management Studio?(如何使用Microsoft SQL Server Management Studio生成数据库的实体关系(ER)图?)
Window functions not working in pd.read_sql; Its shows error(窗口函数在pd.read_sql中不起作用;它显示错误)
(Closed) Leaflet.js: How I can Do Editing Geometry On Specific Object I Select Only?((已关闭)Leaflet.js:如何仅在我选择的特定对象上编辑几何图形?)
in sqlite update trigger with multiple if/Case Conditions(在具有多个IF/CASE条件的SQLite UPDATE触发器中)
Android: Why is Room so slow?(Android:为什么Room这么慢?)