Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 在山狮中建造宝石时出错_Ruby_Macos_Gem_Nokogiri - Fatal编程技术网

Ruby 在山狮中建造宝石时出错

Ruby 在山狮中建造宝石时出错,ruby,macos,gem,nokogiri,Ruby,Macos,Gem,Nokogiri,我刚买了一台新的MacBookPro(显然是w/ML)。我要做的第一件事是安装开发工具。我用rvm安装了Ruby,还安装了自制软件。我不得不下载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-w

我刚买了一台新的MacBookPro(显然是w/ML)。我要做的第一件事是安装开发工具。我用rvm安装了Ruby,还安装了自制软件。我不得不下载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.

看来我有开发工具,所以我无法解决问题。有什么想法吗?

在本例中,您需要libxml的开发头,这些头不是作为编译器工具的一部分提供的。通常,您需要安装一个或来帮助安装这些依赖项

如果您不熟悉,这里的提示在噪音中很难发现,但是:

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

.h
文件随开发包一起提供,是针对这些库编译扩展所必需的。

我不得不四处看看,但我在github找到了解决方案:

缺少libxml2

我发现解决上述问题需要额外的一个步骤 Mac OS X 10.8 Mountain Lion上的0.9,即创建“/usr/bin/gcc-4.2”链接:


谢谢我在Nokogiri网站上找到了使用Homebrew 0.9安装的说明,但仍然收到相同的错误。也许自制0.9.3破坏了其他东西。下一步我会试试MacPorts。
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