gpt4 book ai didi

ruby - 在 Mountain Lion 中构建 gem 时出错

转载 作者:数据小太阳 更新时间:2023-10-29 08:00:47 25 4
gpt4 key购买 nike

我刚买了一台新的 MacBook Pro(显然是带 ML 的)。我要做的第一件事是安装开发工具。我用 rvm 安装了 Ruby,还安装了 Homebrew。我必须下载 XCode 命令行工具。

$ gcc -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~67/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.11~67/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)

我能够很好地安装 mongo gem,但是当我尝试安装 nokogiri 时,出现以下错误:

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

/Users/johnsmith/.rvm/rubies/ruby-1.9.3-p327/bin/ruby extconf.rb
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.

在那条消息之后,它列出了一大堆配置选项,然后说:

/Users/johnsmith/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:369:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.

貌似我有开发工具,所以我想不出问题所在。有什么想法吗?

最佳答案

我不得不四处看看,但我在 github 上找到了解决方案: https://github.com/sparklemotion/nokogiri/issues/442#issuecomment-7978408

libxml2 is missing.

I found one extra step was required to solve the above for Homebrew 0.9 on Mac OS X 10.8 Mountain Lion and that is to create a "/usr/bin/gcc-4.2" link:

brew install libxml2 libxslt
brew link libxml2 libxslt
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
tar xvfz libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local/Cellar/libiconv/1.13.1
make
sudo make install
sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.8.0/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.8.0/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib

关于ruby - 在 Mountain Lion 中构建 gem 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13886494/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com