Heroku的部署失败,因为sqlite3的宝石错误(Heroku deployment faile

2019-06-18 15:23发布

我刚开始由迈克尔·哈特尔在ruby.railstutorial.org书,并已通过第一章的工作。 我使用的是Mac书OS X,终端和崇高的文本。 一切都按计划进行,直到它的时间来测试部署的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会忽略它都在一起,但是这似乎并不如此。

此外,当我创造我使用$包捆绑安装--without生产

我知道有些人已经建议只安装PG和使用,但我真的想坚持到教程尽可能之前,我走出去,并尝试不同的方法。

我有点此刻丢失,不知道如何从这里着手。 你可以提供任何帮助将非常感激。

谢谢

Answer 1:

Heroku上无法安装sqlite3的宝石,无论出于何种原因。 但你能告诉bundler ,它不应该试图开发时除外。

在你Gemfile ,更换gem 'sqlite3'有:

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

然后捆绑在Heroku上,运行的production ,也不会尝试安装它。



Answer 2:

我终于能够成功地部署到Heroku的。 由于evanc3指着我对Heroku的网站的文章。 看来,我只是忘了部署到Heroku的前犯我Gemgile更新。 所以,各位刚开始,你需要确保你部署到Heroku上之前提交更改。



Answer 3:

Heroku的不支持sqlite3的...

从您的Gemfile删除sqlite3的,使用PG宝石来代替。 做下面的宝石中的文件更改

在您更改以下Gemfile

gem 'sqlite3'

gem 'pg' #you will have to install postgresql

重要提示:运行

git add .
git commit 
git push heroku master

注意:如果您计划部署的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

Heroku的会用pg宝石,因为Heroku的运行环境的生产应用程序



Answer 4:

在Heroku上,你的应用程序没有访问文件系统。 有许多的原因 - 它基本上是由于这一事实,你可以扩展通过添加新的实例(即同时运行多个服务器),您的应用程序的性能,以及这些情况下都不能保证是同一台物理机器上 - 复制文件跨越将是极其缓慢。

SQLite的只是数据库存储在你的数据库/文件夹,这就是为什么它的Heroku与不兼容的文件。

最好的选择,因为在帮助链接的建议,是从SQLite的移开,因为有SQLite和PostgreSQL的(选择的Heroku的数据库)之间有时有一些细微的不兼容,你想找到这个部署到生产环境之前

您安装PostgreSQL后(究竟是如何做到这一点取决于您的操作系统),然后加上gem 'pg'到你的Gemfile。



Answer 5:

我有,如果你不要在您的Gemfile直接有sqlite3的一个解决方案,你仍然收到此错误。

最有可能的,你有一个使用sqlite3的作为依赖宝石,它是包括没有你知道的宝石。

1)进入Gemfile.lock的和做sqlite的搜索。

2)找到该宝石使用SQLite然后移动宝石到开发或测试组。

3)软件包



文章来源: Heroku deployment failed because of sqlite3 gem error