mac os 10.10.3 安装rails & Nokogiri

本文记录了在终端使用sudo gem install rails -V时遇到的Nokogiri安装错误,并详细描述了解决过程,最终通过指定libxml2和libxslt的头文件和库的路径成功安装。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

终端输入

sudo gem install rails -V

报错

/Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/test/xslt/test_custom_functions.rb
/Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/test/xslt/test_exception_handling.rb
/Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/test_all
Building native extensions.  This could take a while...
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/ext/builder.rb:51: warning: Insecure world writable dir /usr/bin in PATH, mode 040777
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
checking for gzdopen() in -lz... yes
checking for iconv... no
-----
libiconv is missing.  Please locate mkmf.log to investigate how it is failing.
-----
*** 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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
 --help
 --clean
 --use-system-libraries
 --enable-static
 --disable-static
 --with-zlib-dir
 --without-zlib-dir
 --with-zlib-include
 --without-zlib-include=${zlib-dir}/include
 --with-zlib-lib
 --without-zlib-lib=${zlib-dir}/lib
 --enable-cross-build
 --disable-cross-build
ERROR:  Error installing rails:
 ERROR: Failed to build gem native extension.

    Building has failed. See above output for more information on the failure.

Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2 for inspection.


直接安装Nokogir

按照官网步骤

#sudo gem install nokogiri
同样的错误,失败
#sudo gem install nokogiri --     --use-system-libraries

同样的错误,失败


#sudo gem install nokogiri --  \

   --use-system-libraries  \

   --with-xml2-lib=/usr/lib \

    --with-xml2-include=/usr/include/libxml2  \

   --with-xslt-lib=/usr/lib \

    --with-xslt-include=/usr/include/libxslt

成功


结论,没有找到libxml2和libxslt的头文件和库的路径。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值