在Mac OS X上安装Nokogiri gem时出错

时间:2022-08-09 22:43:58

I was trying to install a connector for Rally and bugzilla on my Mac OSx. While running the install script, it tries to install the gems and it looks for the libxml2 which is already present on my machine.

我试着在我的Mac OSx上安装一个连接器用于集会和bugzilla。在运行安装脚本时,它尝试安装gems,并查找在我的机器上已经存在的libxml2。

This happens when it tries to install nokogiri.

当它试图安装nokogiri时就会发生这种情况。

This is the transcript:

这是记录:

Building native extensions with: '--use-system-libraries'
This could take a while...
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20150121-48754-wgouyu.rb extconf.rb --use-system-libraries
Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-apple-darwin13.4.0/ports/libxml2/2.8.0... OK
Running 'configure' for libxml2 2.8.0... OK
Running 'compile' for libxml2 2.8.0... OK
Running 'install' for libxml2 2.8.0... OK
Activating libxml2 2.8.0 (from /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.1/ports/x86_64-apple-darwin13.4.0/libxml2/2.8.0)...
Extracting libxslt-1.1.26.tar.gz into tmp/x86_64-apple-darwin13.4.0/ports/libxslt/1.1.26... OK
Running 'configure' for libxslt 1.1.26... OK
Running 'compile' for libxslt 1.1.26... OK
Running 'install' for libxslt 1.1.26... OK
Activating libxslt 1.1.26 (from /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.1/ports/x86_64-apple-darwin13.4.0/libxslt/1.1.26)...
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... yes
checking for xmlParseDoc() in -lxml2... no
-----
`  libxml2 is missing.  please visit http://nokogiri.org/tutorials /installing_nokogiri.html for help with installing dependencies.`
-----
*** 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
    --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
    --with-iconvlib
    --without-iconvlib
    --with-xml2lib
    --without-xml2lib

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.1 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-13/2.0.0/nokogiri-1.6.1/gem_make.out

I tried so many options like installing the command line tools by running the below command. xcode-select --install

我尝试了很多选项,比如通过运行下面的命令来安装命令行工具。xcode-select——安装

Adding the symbolic links to gcc compliler

向gcc遵从者添加符号链接

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

I have been struggling for the past two days. Any help is highly apperciated.

过去两天我一直在挣扎。任何帮助都是高度恰当的。

3 个解决方案

#1


5  

If you are using brew use this in the terminal:

如果你正在使用brew应用于终端:

brew unlink gcc-4.2      # you might not need this step
gem uninstall nokogiri
xcode-select --install
gem install nokogiri

If this didn't work please check "Installing Nokogiri on OSX 10.10 Yosemite"

如果不成功,请检查“在OSX 10.10 Yosemite上安装Nokogiri”

#2


4  

Solved the issue with the command

用命令解决了这个问题

sudo ARCHFLAGS="-arch x86_64" gem install nokogiri -v '1.6.1'

thanks for the link pointed out by mohamed abd.

感谢mohamed abd指出的链接。

#3


0  

This worked for me:

这工作对我来说:

sudo gem install nokogiri --no-rdoc --no-ri

#1


5  

If you are using brew use this in the terminal:

如果你正在使用brew应用于终端:

brew unlink gcc-4.2      # you might not need this step
gem uninstall nokogiri
xcode-select --install
gem install nokogiri

If this didn't work please check "Installing Nokogiri on OSX 10.10 Yosemite"

如果不成功,请检查“在OSX 10.10 Yosemite上安装Nokogiri”

#2


4  

Solved the issue with the command

用命令解决了这个问题

sudo ARCHFLAGS="-arch x86_64" gem install nokogiri -v '1.6.1'

thanks for the link pointed out by mohamed abd.

感谢mohamed abd指出的链接。

#3


0  

This worked for me:

这工作对我来说:

sudo gem install nokogiri --no-rdoc --no-ri