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

2024-03-12

我刚刚开始阅读 Michael Hartl 所著的 ruby​​.railstutorial.org 书籍,并且已经完成了第一章。我正在使用 mac book OS X、Terminal 和 Sublime Text。一切都按计划进行,直到测试部署到 Heroku 为止。我能够连接到 Heroku 并运行$ git push heroku主指挥。但部署失败:

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

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 会忽略它,但情况似乎并非如此。

另外,当我创建我正在使用的捆绑包时 $ 捆绑安装--无需生产

我知道有些人建议只安装 PG 并使用它,但在我冒险尝试不同的方法之前,我真的想尽可能地坚持使用教程。

我现在有点迷失,不知道如何从这里继续。如果您能提供任何帮助,我们将不胜感激。

Thanks


无论出于何种原因,Heroku 都无法安装 sqlite3 gem。但你可以告诉bundler除了在开发时之外,它不应该尝试这样做。

In your Gemfile, 代替gem 'sqlite3' with:

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

然后在heroku上打包,运行为production,不会尝试安装它。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

由于 sqlite3 gem 错误,Heroku 部署失败 的相关文章

随机推荐