ruby-on-rails – 安装nokogiri Mac OS X 10.8.2安装XCode

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 安装nokogiri Mac OS X 10.8.2安装XCode前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
试图在山狮上安装nokogiri.我使用红宝石1.8.7,但刚升级到1.9.3,但是它阻止了捆绑安装工作.

顺便提一下,我可以通过卸载ruby 1.9.3并恢复到1.8.7来解决这个问题.然而,这显然是一个次优的解决方案,因为我不想在1.8.7的时间内停留…

  1. Users-MacBook-Pro:sample_app user$ls
  2. Gemfile app doc script
  3. Gemfile.lock config lib spec
  4. README.md config.ru log tmp
  5. Rakefile db public vendor
  6. Ravins-MacBook-Pro:sample_app user$bundle
  7. Fetching gem Metadata from https://rubygems.org/.......
  8. /Users/user/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.1/lib/bundler.rb:263: warning: Insecure world writable dir /usr/local in PATH,mode 040777
  9. Using rake (0.9.2.2)
  10. Using i18n (0.6.1)
  11. Using multi_json (1.3.6)
  12. Using activesupport (3.2.8)
  13. Using builder (3.0.3)
  14. Using activemodel (3.2.8)
  15. Using erubis (2.7.0)
  16. Using journey (1.0.4)
  17. Using rack (1.4.1)
  18. Using rack-cache (1.2)
  19. Using rack-test (0.6.2)
  20. Using hike (1.2.1)
  21. Using tilt (1.3.3)
  22. Using sprockets (2.1.3)
  23. Using actionpack (3.2.8)
  24. Using mime-types (1.19)
  25. Using polyglot (0.3.3)
  26. Using treetop (1.4.10)
  27. Using mail (2.4.4)
  28. Using actionmailer (3.2.8)
  29. Using arel (3.0.2)
  30. Using tzinfo (0.3.33)
  31. Using activerecord (3.2.8)
  32. Using activeresource (3.2.8)
  33. Using addressable (2.3.2)
  34. Installing nokogiri (1.5.5) with native extensions
  35. Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
  36.  
  37. /Users/user/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
  38. extconf.rb:86: warning: Insecure world writable dir /usr/local in PATH,mode 040777
  39. checking for libxml/parser.h... *** extconf.rb Failed ***
  40. Could not create Makefile due to some reason,probably lack of
  41. necessary libraries and/or headers. Check the mkmf.log file for more
  42. details. You may need configuration options.
  43.  
  44. Provided configuration options:
  45. --with-opt-dir
  46. --without-opt-dir
  47. --with-opt-include
  48. --without-opt-include=${opt-dir}/include
  49. --with-opt-lib
  50. --without-opt-lib=${opt-dir}/lib
  51. --with-make-prog
  52. --without-make-prog
  53. --srcdir=.
  54. --curdir
  55. --ruby=/Users/user/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
  56. --with-zlib-dir
  57. --without-zlib-dir
  58. --with-zlib-include
  59. --without-zlib-include=${zlib-dir}/include
  60. --with-zlib-lib
  61. --without-zlib-lib=${zlib-dir}/lib
  62. --with-iconv-dir
  63. --without-iconv-dir
  64. --with-iconv-include
  65. --without-iconv-include=${iconv-dir}/include
  66. --with-iconv-lib
  67. --without-iconv-lib=${iconv-dir}/lib
  68. --with-xml2-dir
  69. --without-xml2-dir
  70. --with-xml2-include
  71. --without-xml2-include=${xml2-dir}/include
  72. --with-xml2-lib
  73. --without-xml2-lib=${xml2-dir}/lib
  74. --with-xslt-dir
  75. --without-xslt-dir
  76. --with-xslt-include
  77. --without-xslt-include=${xslt-dir}/include
  78. --with-xslt-lib
  79. --without-xslt-lib=${xslt-dir}/lib
  80. --with-libxslt-config
  81. --without-libxslt-config
  82. --with-pkg-config
  83. --without-pkg-config
  84. --with-libxml-2.0-config
  85. --without-libxml-2.0-config
  86. --with-pkg-config
  87. --without-pkg-config
  88. --with-libiconv-config
  89. --without-libiconv-config
  90. --with-pkg-config
  91. --without-pkg-config
  92. /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)
  93. You have to install development tools first.
  94. from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'
  95. from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:970:in `block in find_header'
  96. from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
  97. from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
  98. from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open'
  99. from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
  100. from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open'
  101. from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
  102. from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
  103. from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:969:in `find_header'
  104. from extconf.rb:114:in `<main>'
  105.  
  106.  
  107. Gem files will remain installed in /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/nokogiri-1.5.5 for inspection.
  108. Results logged to /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/nokogiri-1.5.5/ext/nokogiri/gem_make.out
  109. An error occurred while installing nokogiri (1.5.5),and Bundler cannot continue.
  110. Make sure that `gem install nokogiri -v '1.5.5'` succeeds before bundling.

我已经下载了XCODE,包括开发工具,所以我不知道为什么它不会安装nokogiri …

当我尝试直接安装nokogiri,我得到:

  1. ERROR: Error installing nokogiri:
  2. ERROR: Failed to build gem native extension.
  3.  
  4. /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
  5. extconf.rb:86: warning: Insecure world writable dir /usr/local in PATH,probably lack of
  6. necessary libraries and/or headers. Check the mkmf.log file for more
  7. details. You may need configuration options.
  8.  
  9. Provided configuration options:
  10. --with-opt-dir
  11. --without-opt-dir
  12. --with-opt-include
  13. --without-opt-include=${opt-dir}/include
  14. --with-opt-lib
  15. --without-opt-lib=${opt-dir}/lib
  16. --with-make-prog
  17. --without-make-prog
  18. --srcdir=.
  19. --curdir
  20. --ruby=/Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
  21. --with-zlib-dir
  22. --without-zlib-dir
  23. --with-zlib-include
  24. --without-zlib-include=${zlib-dir}/include
  25. --with-zlib-lib
  26. --without-zlib-lib=${zlib-dir}/lib
  27. --with-iconv-dir
  28. --without-iconv-dir
  29. --with-iconv-include
  30. --without-iconv-include=${iconv-dir}/include
  31. --with-iconv-lib
  32. --without-iconv-lib=${iconv-dir}/lib
  33. --with-xml2-dir
  34. --without-xml2-dir
  35. --with-xml2-include
  36. --without-xml2-include=${xml2-dir}/include
  37. --with-xml2-lib
  38. --without-xml2-lib=${xml2-dir}/lib
  39. --with-xslt-dir
  40. --without-xslt-dir
  41. --with-xslt-include
  42. --without-xslt-include=${xslt-dir}/include
  43. --with-xslt-lib
  44. --without-xslt-lib=${xslt-dir}/lib
  45. --with-libxslt-config
  46. --without-libxslt-config
  47. --with-pkg-config
  48. --without-pkg-config
  49. --with-libxml-2.0-config
  50. --without-libxml-2.0-config
  51. --with-pkg-config
  52. --without-pkg-config
  53. --with-libiconv-config
  54. --without-libiconv-config
  55. --with-pkg-config
  56. --without-pkg-config
  57. /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)
  58. You have to install development tools first.
  59. from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'
  60. from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:970:in `block in find_header'
  61. from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
  62. from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
  63. from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open'
  64. from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
  65. from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open'
  66. from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
  67. from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
  68. from /Users/ravinthambapillai/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:969:in `find_header'
  69. from extconf.rb:114:in `<main>'
  70.  
  71.  
  72. Gem files will remain installed in /Users/ravinthambapillai/.rvm/gems/ruby-1.9.3-p194/gems/nokogiri-1.5.5 for inspection.
  73. Results logged to /Users/ravinthambapillai/.rvm/gems/ruby-1.9.3-p194/gems/nokogiri-1.5.5/ext/nokogiri/gem_make.out

谢谢,

解决方法

经过短时间的研究,我发现可以通过创建符号链接简单地解决什么问题
  1. sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2

为我工作也希望你

  1. gem install nokogiri
  2. Building native extensions. This could take a while...
  3. ERROR: Error installing nokogiri:
  4. ERROR: Failed to build gem native extension.
  5.  
  6. /Users/morozovm/.rvm/rubies/ruby-1.9.3-p327/bin/ruby extconf.rb
  7. checking for libxml/parser.h... *** extconf.rb Failed ***
  8.  
  9. bash-3.2$sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
  10. Password:
  11. bash-3.2$gem install nokogiri
  12. Building native extensions. This could take a while...
  13. Successfully installed nokogiri-1.5.6
  14. 1 gem installed

猜你在找的Ruby相关文章