2012-05-04 41 views
23

我跟隨this tutorial,但嘗試推向Heroku時失敗。似乎「sqlite3.h」缺失。我是開發新手,所以我不確定哪些信息會幫助人們診斷問題,所以這裏就是一切:)。我在Mac OS X 10.7 Lion上運行。這裏是我正在使用的所有版本:向Heroku推送Rails應用時缺少「sqlite3.h」

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/ | [email protected]: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 [email protected]:blazing-mountain-3659.git 
! [remote rejected] master -> master (pre-receive hook declined) 
error: failed to push some refs to '[email protected]: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」和第二條命令「未能推送一些文件到[email protected]:blazing-mountain-3659.git」之間的差異有關係?

回答

25

Heroku使用postgresql,因此您想要刪除sqlite3或將其移到您的Gemfile中的開發組中。

檢查你的Gemfile.lock是否有任何其他可能依賴sqlite3的gem,因爲這也會導致問題。

+0

謝謝,現在工作! –

+1

從gemfile中刪除sqlite3並保存gem文件,並檢查gemfile.lock並確認沒有其他引用 - 那麼 - 接下來的步驟是什麼?我仍然在向Heroku求助並獲得相同的錯誤 - 但我覺得現在不應該在尋找sqlite3。 – stopshinal

+3

@stopshinal不要忘記在本地再次提交gem文件中的更改,然後再次將其推入到heroku中 –

4

我有一個類似的問題,我是不是即使使用sqlite3的任何東西,但在寶石文件取出後我仍然有這個錯誤

什麼解決了這個問題對我來說是一個commit命令

git commit -am 

,我就發現this tutorial

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
+4

Thanx!這是我的解決方案。 – Martin

+3

訣竅感謝 – Aspen

+3

謝謝。它解決了我的問題,雖然它沒有被OP選中。 – newguy

1

發生了什麼事我的是,我正沿着Heroku的教程以下,當我用git push heroku master它是從推我最新的Git commit(顯然!)

我忘了在Git的眼中,我仍然在gemfile中使用sqlite!傻我!

所以我用git add .後跟git commit -m "Changed to Postgres.",所以Git知道這些變化。推之後,對我來說工作得很好。

相關問題