2013-10-03 32 views
1

所以我想安裝audite gem,但rbenv有問題:rbenv和需要C擴展寶石

$ bundle install 
Fetching gem metadata from https://rubygems.org/... 
Installing audite (0.3.0) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. 

     /opt/boxen/rbenv/versions/1.9.3-p448/bin/ruby extconf.rb 
checking for mpg123.h... no 
*** 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=/opt/boxen/rbenv/versions/1.9.3-p448/bin/ruby 
please install mpg123 headers 


Gem files will remain installed in /opt/boxen/rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/audite-0.3.0  for inspection. 
Results logged to /opt/boxen/rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/audite-0.3.0/ext/mpg123/gem_make. out 

An error occurred while installing audite (0.3.0), and Bundler cannot continue. 
Make sure that `gem install audite -v '0.3.0'` succeeds before bundling. 

我知道這些寶石需要C擴展,我已經用他們自制安裝。如果我進入地窖自制軟件,我可以看到它在尋找(mpg123.h

/opt/boxen/homebrew/Cellar/mpg123/1.15.4/include/mpg123.h 

所以文件,有沒有辦法添加到rbenv環境中,這不只是SIM聯或直接複製成/opt/boxen/rbenv/versions/1.9.3-p448/

回答

0

所以,我不知道這是因爲我會重建,改變了我的機器幾次,因爲我有這個問題:

  • 切換到Ruby 2.0.0
  • 升級到小牛(這確實改變了一些東西 和Xcode的東西,我相信)
  • 更新我的Boxen有/釀造到最新版本
0

添加自制的include目錄到你的路徑,rubygems會發現它。這對rbenv來說並不是一個問題。

在默認安裝中,自制軟件符號鏈接軟件包的所有include文件夾到/usr/local/include,對於您的情況,這些應該在/opt/boxen/homebrew/include。只要看看周圍,應該有一個文件夾包含所有包含。

+0

很抱歉,您意思是在我的路徑中添加'/ opt/boxen/homebrew/Cellar/mpg123/1.15.4/include /'?那麼我不需要爲每個擴展需要做這件事,因爲我也有類似的問題portaudio ... –

+0

在默認的自制軟件安裝(到'/ usr/local')它會創建一個'/ usr/local/include'文件夾。這也應該存在於'/ opt/boxen/homebrew/include'中。該文件夾包含指向包的各個'include'目錄的符號鏈接。 – Femaref

+0

我給它一個嘗試,但沒有骰子,我的輸出作爲一個要點:https://gist.github.com/petems/6812615 –

1

我遇到了試圖安裝audite的相同問題。原來,MKMF寫入文件調用mkmf.log告訴你更具體地說它做什麼,以找出是否標題是availbale與否:

>>> cat mkmf.log 
have_header: checking for mpg123.h... -------------------- no 

"xcrun cc -E -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE  -g -Os -pipe -fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common conftest.c -o conftest.i" 
xcode-select: Error: No Xcode is selected. Use xcode-select -switch <path-to-xcode>, or see the xcode-select manpage (man xcode-select) for further information. 
checked program was: 
/* begin */ 
1: #include <mpg123.h> 
/* end */ 

-------------------- 

原來,我還沒有尚未安裝的Xcode;安裝並運行後

xcode-select --print-path 

我看到現在設置了路徑。然後,我仍然不得不運行xcrun曾經同意蘋果的許可協議,但後來安裝安裝就好!

+0

沒有骰子不幸,但該日誌文件是有用的: https://gist.github.com/petems/7791532 –

+0

好奇!也許嘗試創建一個/ usr/var/lib目錄並將其鏈接到/ var/lib? – LyrixDeRaven

+0

現在略有不同的錯誤:https://gist.github.com/petems/7891928 –

2
xcode-select --install 

爲我解決了它。

到底有下列情況之一的固定對我來說