2012-09-29 70 views
12

試圖在山獅上安裝nokogiri。我使用紅寶石1.8.7,但剛剛升級到1.9.3,但它停止了捆綁安裝工作。安裝nokogiri Mac OS X 10.8.2安裝XCode

順便說一下,我可以通過卸載ruby 1.9.3和恢復到1.8.7來解決這個問題。然而,這顯然是一個次優的解決方案,因爲我不想被卡在1.8.7的時間休息...

Users-MacBook-Pro:sample_app user$ ls 
Gemfile  app  doc  script 
Gemfile.lock config  lib  spec 
README.md config.ru log  tmp 
Rakefile db  public  vendor 
Ravins-MacBook-Pro:sample_app user$ bundle 
Fetching gem metadata from https://rubygems.org/....... 
/Users/user/.rvm/gems/[email protected]/gems/bundler-1.2.1/lib/bundler.rb:263: warning: Insecure world writable dir /usr/local in PATH, mode 040777 
Using rake (0.9.2.2) 
Using i18n (0.6.1) 
Using multi_json (1.3.6) 
Using activesupport (3.2.8) 
Using builder (3.0.3) 
Using activemodel (3.2.8) 
Using erubis (2.7.0) 
Using journey (1.0.4) 
Using rack (1.4.1) 
Using rack-cache (1.2) 
Using rack-test (0.6.2) 
Using hike (1.2.1) 
Using tilt (1.3.3) 
Using sprockets (2.1.3) 
Using actionpack (3.2.8) 
Using mime-types (1.19) 
Using polyglot (0.3.3) 
Using treetop (1.4.10) 
Using mail (2.4.4) 
Using actionmailer (3.2.8) 
Using arel (3.0.2) 
Using tzinfo (0.3.33) 
Using activerecord (3.2.8) 
Using activeresource (3.2.8) 
Using addressable (2.3.2) 
Installing nokogiri (1.5.5) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. 

     /Users/user/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb 
extconf.rb:86: warning: Insecure world writable dir /usr/local in PATH, mode 040777 
checking for libxml/parser.h... *** 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=/Users/user/.rvm/rubies/ruby-1.9.3-p194/bin/ruby 
    --with-zlib-dir 
    --without-zlib-dir 
    --with-zlib-include 
    --without-zlib-include=${zlib-dir}/include 
    --with-zlib-lib 
    --without-zlib-lib=${zlib-dir}/lib 
    --with-iconv-dir 
    --without-iconv-dir 
    --with-iconv-include 
    --without-iconv-include=${iconv-dir}/include 
    --with-iconv-lib 
    --without-iconv-lib=${iconv-dir}/lib 
    --with-xml2-dir 
    --without-xml2-dir 
    --with-xml2-include 
    --without-xml2-include=${xml2-dir}/include 
    --with-xml2-lib 
    --without-xml2-lib=${xml2-dir}/lib 
    --with-xslt-dir 
    --without-xslt-dir 
    --with-xslt-include 
    --without-xslt-include=${xslt-dir}/include 
    --with-xslt-lib 
    --without-xslt-lib=${xslt-dir}/lib 
    --with-libxslt-config 
    --without-libxslt-config 
    --with-pkg-config 
    --without-pkg-config 
    --with-libxml-2.0-config 
    --without-libxml-2.0-config 
    --with-pkg-config 
    --without-pkg-config 
    --with-libiconv-config 
    --without-libiconv-config 
    --with-pkg-config 
    --without-pkg-config 
/Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError) 
You have to install development tools first. 
    from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp' 
    from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:970:in `block in find_header' 
    from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for' 
    from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone' 
    from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open' 
    from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone' 
    from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open' 
    from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:280:in `postpone' 
    from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for' 
    from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:969:in `find_header' 
    from extconf.rb:114:in `<main>' 


Gem files will remain installed in /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/nokogiri-1.5.5 for inspection. 
Results logged to /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/nokogiri-1.5.5/ext/nokogiri/gem_make.out 
An error occurred while installing nokogiri (1.5.5), and Bundler cannot continue. 
Make sure that `gem install nokogiri -v '1.5.5'` succeeds before bundling. 

我已經下載XCODE包括開發工具,所以我不知道爲什麼它不會安裝引入nokogiri ...

當我試圖直接安裝引入nokogiri,我得到:

ERROR: Error installing nokogiri: 
    ERROR: Failed to build gem native extension. 

     /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb 
extconf.rb:86: warning: Insecure world writable dir /usr/local in PATH, mode 040777 
checking for libxml/parser.h... *** 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=/Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/bin/ruby 
    --with-zlib-dir 
    --without-zlib-dir 
    --with-zlib-include 
    --without-zlib-include=${zlib-dir}/include 
    --with-zlib-lib 
    --without-zlib-lib=${zlib-dir}/lib 
    --with-iconv-dir 
    --without-iconv-dir 
    --with-iconv-include 
    --without-iconv-include=${iconv-dir}/include 
    --with-iconv-lib 
    --without-iconv-lib=${iconv-dir}/lib 
    --with-xml2-dir 
    --without-xml2-dir 
    --with-xml2-include 
    --without-xml2-include=${xml2-dir}/include 
    --with-xml2-lib 
    --without-xml2-lib=${xml2-dir}/lib 
    --with-xslt-dir 
    --without-xslt-dir 
    --with-xslt-include 
    --without-xslt-include=${xslt-dir}/include 
    --with-xslt-lib 
    --without-xslt-lib=${xslt-dir}/lib 
    --with-libxslt-config 
    --without-libxslt-config 
    --with-pkg-config 
    --without-pkg-config 
    --with-libxml-2.0-config 
    --without-libxml-2.0-config 
    --with-pkg-config 
    --without-pkg-config 
    --with-libiconv-config 
    --without-libiconv-config 
    --with-pkg-config 
    --without-pkg-config 
/Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError) 
You have to install development tools first. 
    from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp' 
    from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:970:in `block in find_header' 
    from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for' 
    from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone' 
    from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open' 
    from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone' 
    from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open' 
    from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:280:in `postpone' 
    from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for' 
    from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:969:in `find_header' 
    from extconf.rb:114:in `<main>' 


Gem files will remain installed in /Users/ravinthambapillai/.rvm/gems/ruby-1.9.3-p194/gems/nokogiri-1.5.5 for inspection. 
Results logged to /Users/ravinthambapillai/.rvm/gems/ruby-1.9.3-p194/gems/nokogiri-1.5.5/ext/nokogiri/gem_make.out 

developer tools components tab 感謝,

developer tools install photo

+0

我假設你去嘗試直接安裝nokogiri相同的結果埠ndle? –

+0

我剛剛添加了錯誤信息,當我試圖直接安裝nokogiri到答案 – Ravin

+1

@ravin這不是命令行工具的問題.. –

回答

30

短暫研究後,我發現什麼問題可以給我創建符號鏈接

sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2 

作品簡單地加以解決希望你也

gem install nokogiri 
Building native extensions. This could take a while... 
ERROR: Error installing nokogiri: 
    ERROR: Failed to build gem native extension. 

     /Users/morozovm/.rvm/rubies/ruby-1.9.3-p327/bin/ruby extconf.rb 
checking for libxml/parser.h... *** extconf.rb failed *** 

bash-3.2$ sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2 
Password: 
bash-3.2$ gem install nokogiri 
Building native extensions. This could take a while... 
Successfully installed nokogiri-1.5.6 
1 gem installed 
+1

它也適用於我。我知道這是一個問題,但認真......如何失去你的時間... – Nazka

+1

完美。爲我工作。將Xcode升級到版本5(Rails 4,Ruby 2.0.0-p195)時遇到問題, – Ari53nN3o

-3

我認爲這是錯誤信息的最重要的一點:

warning: Insecure world writable dir /usr/local in PATH, mode 040777 

構建過程的一些部分是抱怨該目錄具有權限,使任何人都可以寫入。你可以嘗試追捕它 - 或者你可以修復它。

+1

根本不是。這完全沒有關係。 –

1

試試這些。我面臨同樣的問題,併爲我工作。首先安裝libxml2,然後再次運行bundler。

brew install libxml2 
brew link libxml2 

來源:http://decielo.com/articles/11/rails-3-on-lion-hey-ho-lets-go

更新:

我希望你已經安裝自制軟件。如果你沒有自制軟件,那麼我會建議你安裝自制軟件,然後安裝libxml2和捆綁軟件。如果您沒有自制軟件,請勿使用mac端口。

更新:

這不是命令行工具的問題。它在libxml上失敗。嘗試讀取錯誤,你會看到

checking for libxml/parser.h... *** extconf.rb failed *** 

這就是問題

+2

可悲的是,這並沒有幫助我(我有一個相同的問題)。我已經鏈接了'libxml2'和'libxslt',但是我還是得到了'libxml/parser.h' @Ravin在上面。還有什麼建議? –

+0

U得到相同的錯誤?檢查libxml/parser.h ... *** extconf.rb失敗*** –