2014-05-10 127 views
1

我在OSX Marvericks上使用rvm。 從bundler安裝nokogiri等原生擴展失敗。 但從寶石命令安裝工程。在OSX上捆綁安裝失敗10.9

我還安裝了最新的XCode命令行工具。

我不知道捆綁安裝和gem安裝有什麼區別。

 
$ rvm requirements 
Checking requirements for osx. 
Certificates in '/usr/local/etc/openssl/cert.pem' already are up to date. 
Requirements installation successful. 
Yusuke-no-MacBook-Air-2:doorkeeper-jp-admin yandod$ bundle install 
Fetching gem metadata from https://rubygems.org/......... 
Fetching additional metadata from https://rubygems.org/.. 
Resolving dependencies... 
Using rake 10.3.1 
Using bundler 1.6.2 
Using mini_portile 0.5.3 

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 

    /Users/yandod/.rvm/rubies/ruby-2.0.0-p451-rvm/bin/ruby extconf.rb 
/Users/yandod/.rvm/rubies/ruby-2.0.0-p451-rvm/bin/ruby: invalid option -H (-h will show valid options) (RuntimeError) 

extconf failed, exit code 1 

Gem files will remain installed in /Volumes/Macintosh HD 2/develop/doorkeeper-jp-admin/vendor/bundle/gems/nokogiri-1.6.1 for inspection. 
Results logged to /Volumes/Macintosh HD 2/develop/doorkeeper-jp-admin/vendor/bundle/extensions/x86_64-darwin-13/2.0.0/nokogiri-1.6.1/gem_make.out 
An error occurred while installing nokogiri (1.6.1), and Bundler cannot continue. 
Make sure that `gem install nokogiri -v '1.6.1'` succeeds before bundling. 

gem install的結果。

 
$ gem install nokogiri -v '1.6.1' 
Building native extensions. This could take a while... 
Successfully installed nokogiri-1.6.1 
1 gem installed 

版本的相關軟件:

 
$ bundle --version 
Bundler version 1.6.2 
$ rvm --version 

rvm 1.25.25 (stable) by Wayne E. Seguin , Michal Papis [https://rvm.io/] 
$ gem --version 
2.2.2 

補充說: 我捆綁配置

 
$ cat ~/.bundle/config 
BUNDLE_PATH: ./vendor/bundle 
BUNDLE_BUILD__NOKOGIRI: --use-system-libraries --with-iconv-dir=/usr/local/opt/libiconv --with-xml2-config=/usr/local/opt/libxml2/bin/xml2-config --with-xslt-config=/usr/local/opt/libxslt/bin/xslt-config 
+1

'''bundle install'''在安裝好gem後仍然失敗? – eduardo

+0

即使在「gem install」後它仍然失敗 –

+0

如果安裝了gem,bundler不應該嘗試再次安裝它(在這些情況下,bundler說'使用'而不是'安裝')。你可能在運行gem install nokogiri'''的時候運行'''bundle install'''在另一個ruby/gemset中運行? – eduardo

回答

0

當您執行gem install時,gem會安裝到您的默認系統位置(您可以看到gem env的輸出)。

但是當您在做bundle install時,您將gem安裝到系統的gem存儲庫以外的位置(因爲您已爲您的軟件包BUNDLE_PATH=./vendor/bundle配置了自定義路徑),所以Bundler將安裝gems,重新出現在系統的gem倉庫中,因爲你沒有使用它。

現在,由於某種原因,gem命令沒有問題找到構建gem本地擴展所需的系統庫,但Bundler具有。所以你必須做的是指導Bundler這些庫的路徑。

因此,假設你使用自制:

  • 確保你已經安裝了所有的本地依賴性:
    brew install libxml2 libxslt libiconv

  • 指示捆紮機如何建立創業板引入nokogiri:
    bundle config build.nokogiri --use-system-libraries --with-iconv-dir="$(brew --prefix libiconv)" --with-xml2-config="$(brew --prefix libxml2)/bin/xml2-config" --with-xslt-config="$(brew --prefix libxslt)/bin/xslt-config"

  • 安裝捆綁包,發信號nokogiri使用上述l ibraries: NOKOGIRI_USE_SYSTEM_LIBRARIES=1 bundle install

這應該是它。

編輯:

雖然上面的步驟可能仍然是必要的,它似乎是實際問題是在項目的路徑「空間」字符的存在。

看到取消設置捆綁包路徑選項會使其正常工作,我已仔細檢查了原始的bundle install輸出,並且我意識到您正在使用它看起來像外部驅動器,其外部驅動器上帶有「空格」字符名稱。

包括'空格'或特殊字符的項目路徑通常是很多工具的問題,因此您應該避免使用它們。請嘗試重新命名您的音量或將您的項目移至其他位置。

對不起,我沒有意識到之前。

+0

我跟着步你顯示。但仍然看到同樣的錯誤。 –

+0

您是否可以嘗試在項目目錄下取消設置包路徑以查看它是否成功? – eduardo

+0

取消設置束路徑使事情起作用。 現在不使用捆綁路徑可以解決這個問題。 –

0

嘗試: rvm get stable

則: rvm reload

+0

我做到了,但仍然失敗。 –

+0

錯誤消息與以前一樣。 –

+0

你使用自制軟件? – matanco