无法推送到Heroku - 缺少sqlite3.h

8

这是我第一次在这里发帖=) 预先感谢您的帮助,目前任何帮助都很酷!

1- 在考虑在stackoverflow上发布问题之前,我进行了很多搜索并尝试了许多方法。

2- 运行时,出现了错误消息“

”。

   git push heroku master

I get this:

   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).

3- 我已经检查了Gemfile文件:生产环境和开发/测试环境都已经正确配置为使用pg和sqlite3数据库。

4- Sqlite3.h文件在这里:

   pcbo$ ls -l /usr/include/sqlite3.h
   -rw-r--r--  1 root  wheel  322724  7 Dec  2011 /usr/include/sqlite3.h

5- 忘记提到我正在使用的是 Mac OS X。

6- 输出结果为: pcbo$ git push heroku master

    Counting objects: 71, done.
    Delta compression using up to 4 threads.
    Compressing objects: 100% (58/58), done.
    Writing objects: 100% (71/71), 26.46 KiB, done.
    Total 71 (delta 8), reused 0 (delta 0)

    -----> Heroku receiving push
    -----> Ruby/Rails app detected
    -----> Installing dependencies using Bundler version 1.2.0.pre
    Running: bundle install --without development:test --path vendor/bundle --binstubs bin/ --deployment
   Fetching gem metadata from https://rubygems.org/.......
   Installing rake (0.9.2.2)
   Installing i18n (0.6.0)
   Installing multi_json (1.3.6)
   Installing activesupport (3.2.3)
   Installing builder (3.0.0)
   Installing activemodel (3.2.3)
   Installing erubis (2.7.0)
   Installing journey (1.0.3)
   Installing rack (1.4.1)
   Installing rack-cache (1.2)
   Installing rack-test (0.6.1)
   Installing hike (1.2.1)
   Installing tilt (1.3.3)
   Installing sprockets (2.1.3)
   Installing actionpack (3.2.3)
   Installing mime-types (1.18)
   Installing polyglot (0.3.3)
   Installing treetop (1.4.10)
   Installing mail (2.4.4)
   Installing actionmailer (3.2.3)
   Installing arel (3.0.2)
   Installing tzinfo (0.3.33)
   Installing activerecord (3.2.3)
   Installing activeresource (3.2.3)
   Installing coffee-script-source (1.3.3)
   Installing execjs (1.4.0)
   Installing coffee-script (2.2.0)
   Installing rack-ssl (1.3.2)
   Installing json (1.7.3) with native extensions
   Installing rdoc (3.12)
   Installing thor (0.14.6)
   Installing railties (3.2.3)
   Installing coffee-rails (3.2.2)
   Installing jquery-rails (2.0.2)
   Installing pg (0.12.2) with native extensions
   Using bundler (1.2.0.pre)
   Installing rails (3.2.3)
   Installing sass (3.1.19)
   Installing sass-rails (3.2.5)
   Installing sqlite3 (1.3.6) 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:
   --with-opt-dir
   --without-opt-dir
   --with-opt-include
   --without-opt-include=${opt-dir}/include
   --with-opt-lib
   --without-opt-lib=${opt-dir}/lib
   --with-make-prog
   --without-make-prog
   --srcdir=.
   --curdir
   --ruby=/usr/local/bin/ruby
   --with-sqlite3-dir
   --without-sqlite3-dir
   --with-sqlite3-include
   --without-sqlite3-include=${sqlite3-dir}/include
   --with-sqlite3-lib
   --without-sqlite3-lib=${sqlite3-dir}/lib
   --enable-local
   --disable-local
   Gem files will remain installed in /tmp/build_zmjrcoagwpai/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.6 for inspection.
   Results logged to /tmp/build_zmjrcoagwpai/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.6/ext/sqlite3/gem_make.out
   An error occurred while installing sqlite3 (1.3.6), and Bundler cannot continue.
   Make sure that `gem install sqlite3 -v '1.3.6'` succeeds before bundling.
   !
   !     Failed to install gems via Bundler.
   !
   !     Heroku push rejected, failed to compile Ruby/rails app

7- 任何帮助都非常感激!


这是来自你的本地开发机还是将运行你软件的 Heroku 机器的 ls -l 输出? - sarnold
@sarnold:这是我的本地开发机。 - pcbo
1
@ismaelga:我从Gemfile.lock中删除了所有对sqlite3的引用 - 仍然出现错误:“缺少sqlite3.h”。 - pcbo
我删除了那个评论,因为我认为它实际上没有任何影响。除非检查生产环境中是否有任何依赖于sqlite的gem。 - Ismael
在进行新的 git push 之前,您是否已经提交了对 Gemfile* 文件所做的更改? - Jon Mountjoy
显示剩余2条评论
2个回答

11

[更新1]

根据你的Git推送日志,这是罪魁祸首:

 Installing sqlite3 (1.3.6) with native extensions

所以,正如我最初怀疑的那样,blunder正在尝试加载sqlite3 gem,这在heroku上将会失败。就像之前说过的,这可能是由于两个原因造成的:

  1. Gemfile在生产环境下错误地配置了需要sqlite3 gem。
  2. 其他一些gem依赖于sqlite3 gem。使用gem dependency命令显示gem的依赖关系,并删除依赖于sqlite3的gem。

然后重新运行bundle install,它就可以工作了。

---[更新1结束]---

你能够得到这个错误的唯一原因是,在heroku上尝试使用不支持的sqlite3数据库。因此,请仔细检查你的Gemfile,确保它的设置与这个类似。

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

然后执行bundle install重新生成Gemfile.lock文件。现在,尝试将其推送到heroku。如果仍然出现此错误,则可能是您正在使用的某个gem在其gemspec文件中将sqlite3列为硬编码依赖项。因此实际上加载了sqlite3,即使它不在gemfile中。要验证这一点,在本地主机上运行以下命令:

$ bundle install | grep sqlite

最后,尝试了这个方法之后,它并没有起作用。发帖时请附上git push heroku master完整日志和heroku logs的输出。


嗨@Gaurish。正如我之前提到的,Gemfile已正确配置,并且bundle install | grep sqlite返回Using sqlite3 (1.3.6)现在正在检查如何检索heroku日志 - pcbo
Heroku日志: 2012-06-12T00:53:42 + 00:00 heroku [slugc]:Slug编译已启动 2012-06-12T00:54:09 + 00:00 heroku [slugc]:Slug编译失败:无法编译Ruby / rails应用程序 2012-06-12T09:20:31 + 00:00 heroku [slugc]:Slug编译已启动 2012-06-12T09:21:04 + 00:00 heroku [slugc]:Slug编译失败:无法编译Ruby / rails应用程序这是您所要求的日志吗?没有提供太多信息... - pcbo
git push heroku master 的日志在原问题中(步骤6)中。 - pcbo
当我执行 pcbo$ gem dependency sqlite3 时,我得到了以下结果:Gem sqlite3-1.3.6  hoe (> 3.0, development)  mini_portile (> 0.2.2, development)  rake-compiler (> 0.7.0, development)  rdoc (> 3.10, development)Gem sqlite3-ruby-1.3.3  hoe (>= 2.8.0, development)  sqlite3 (>= 1.3.3)有两个sqlite是正常的吗? - pcbo
2
@Gaurish...我忘记将更改添加到git中,因此什么也没有发生。问题解决了 :) 感谢你的帮助! - pcbo
显示剩余3条评论

0

似乎缺少sqlite库。 请尝试查找它

whereis sqlite3.h

如果在您的系统中,尝试以下操作:
sudo gem install sqlite3-ruby -- --with-sqlite3-include=<"url where it is(for eg: /usr/include)">

致敬


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接