24

我正在关注本教程,但是当我尝试推送到 Heroku 时它失败了。似乎缺少“sqlite3.h”。我是开发新手,所以我不确定哪些信息可以帮助人们诊断问题,所以这里有一切:)。我在 Mac OS X 10.7 Lion 上运行。以下是我正在使用的所有内容的版本:

Amits-MacBook-Air-2:demo_app amitgupta$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.3.0]
Amits-MacBook-Air-2:demo_app amitgupta$ rails -v
Rails 3.2.3
Amits-MacBook-Air-2:demo_app amitgupta$ sqlite3 -version
3.7.11 2012-03-20 11:35:50 00bb9c9ce4f465e6ac321ced2a9d0062dc364669
Amits-MacBook-Air-2:demo_app amitgupta$ heroku -v
2.25.0
Amits-MacBook-Air-2:demo_app amitgupta$ port -v
MacPorts 2.0.4
Entering interactive mode... ("help" for help, "quit" to quit)
[RailsApps/demo_app] > quit 
Goodbye

当我尝试推送到 Heroku 时:

Amits-MacBook-Air-2:demo_app amitgupta$ heroku create --stack cedar
Creating floating-stream-8009... done, stack is cedar
http://floating-stream-8009.herokuapp.com/ | git@heroku.com:floating-stream-8009.git
Amits-MacBook-Air-2:demo_app amitgupta$ git push heroku master

这是我得到的:

Counting objects: 119, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (104/104), done.
Writing objects: 100% (119/119), 33.74 KiB, done.
Total 119 (delta 17), reused 0 (delta 0)

-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.1.2
       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 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
       .
       .
       .
       --disable-local
       Gem files will remain installed in /tmp/build_2l2dn7bx7lu34/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.6 for inspection.
       Results logged to /tmp/build_2l2dn7bx7lu34/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.6/ext/sqlite3/gem_make.out
       An error occured 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

To git@heroku.com:blazing-mountain-3659.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:blazing-mountain-3659.git'

当我做:

Amits-MacBook-Air-2:demo_app amitgupta$ sudo port install sqlite3 +universal

我得到:

Password:
--->  Computing dependencies for sqlite3
--->  Cleaning sqlite3

接下来我尝试了:

Amits-MacBook-Air-2:demo_app amitgupta$ sudo gem install sqlite3 -v '1.3.6'

并得到:

Building native extensions.  This could take a while...
Successfully installed sqlite3-1.3.6
1 gem installed
Installing ri documentation for sqlite3-1.3.6...
Installing RDoc documentation for sqlite3-1.3.6...

然后:

Amits-MacBook-Air-2:demo_app amitgupta$ bundle install

给出:

Using rake (0.9.2.2) 
.
.
.
Using sqlite3 (1.3.6) 
Using uglifier (1.2.4) 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

然后我尝试再次推送到 Heroku,但遇到了同样的问题。也许它与第一个命令“Creating floating-stream-8009”和第二个命令“未能将一些参考推送到'git@heroku.com:blazing-mountain-3659.git'”之间的差异有关?

4

5 回答 5

53
gem 'sqlite3', :group => [:development, :test]
group :production do
  gem 'pg'
end
  1. 编辑Gemfile如上
  2. 消除Gemfile.lock
  3. bundle install --without production
  4. git add .
  5. git commit -am "bundle updating sqlite3"
  6. git push heroku master
于 2012-07-06T05:39:24.440 回答
25

Heroku 使用 postgresql,因此您想删除 sqlite3 或将其移至 Gemfile 中的开发组。

检查 Gemfile.lock 是否有任何其他可能依赖于 sqlite3 的 gem,因为这也会导致问题。

于 2012-05-04T20:25:11.343 回答
4

我有一个类似的问题,我什至没有使用 sqlite3,但是在从 gem 文件中删除它之后,我仍然得到了那个错误

为我解决的是一个提交命令

git commit -am 

我在本教程中找到的

于 2012-06-10T03:51:29.797 回答
1

发生在我身上的是,我正在关注 Heroku 教程,当我使用git push heroku master它时,它是从我最新的 Git 提交中推送的(显然!)

我忘记的是,在 Git 的眼里,我还在 gemfile 中使用 sqlite!傻我!

所以我用git add .了一个git commit -m "Changed to Postgres.",所以 Git 知道了这些变化。之后推动对我来说效果很好。

于 2012-11-28T01:14:48.520 回答
0

是的,正如这些答案所暗示的,由于 Heroku 平台的限制,大多数时候您会希望避免在生产中使用 SQLite 。但是,无论如何,您可能有一个完全可以接受的用例(例如只读配置)来使用 SQLite。我的建议是:

  1. 添加heroku-buildpack-apt构建包

  2. 添加到您的Aptfile

    libsqlite3-dev
    libsqlite3-0
    
于 2020-06-21T18:47:03.423 回答