gpt4 book ai didi

ruby-on-rails - Rails 无法安装 nokogiri w Mavericks 和 rbenv

转载 作者:行者123 更新时间:2023-12-04 05:41:51 27 4
gpt4 key购买 nike

运行 OSX 10.9.4 和 XCode 5.1.1,我最近从 rvm 切换到 Rbenv,所以我需要重新安装一些 gems,没什么大不了的,但是......

即使在下载并安装 10 月份版本的 XCode 命令行工具并运行之后,我仍无法安装 Nokogiri gem:

sudo xcode-select -s /Library/Developer/CommandLineTools/

我还安装了 libxml2 libxslt wbrew

我仍然收到错误,有什么办法可以解决这个问题吗?

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

/Users/yves/.rbenv/versions/2.1.2/bin/ruby extconf.rb
Building nokogiri using packaged libraries.
checking for iconv.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.

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=/Users/yves/.rbenv/versions/2.1.2/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
/Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:587:in `try_cpp'
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:1067:in `block in have_header'
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:918:in `block in checking_for'
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:351:in `block (2 levels) in postpone'
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:321:in `open'
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:351:in `block in postpone'
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:321:in `open'
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:347:in `postpone'
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:917:in `checking_for'
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:1066:in `have_header'
from extconf.rb:103:in `have_iconv?'
from extconf.rb:148:in `block (2 levels) in iconv_prefix'
from extconf.rb:90:in `preserving_globals'
from extconf.rb:143:in `block in iconv_prefix'
from extconf.rb:120:in `each_iconv_idir'
from extconf.rb:137:in `iconv_prefix'
from extconf.rb:427:in `block in <main>'
from extconf.rb:161:in `block in process_recipe'
from extconf.rb:154:in `tap'
from extconf.rb:154:in `process_recipe'
from extconf.rb:422:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /Users/yves/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/nokogiri-1.6.3 for inspection.
Results logged to /Users/yves/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/nokogiri-1.6.3/gem_make.out

安装 libxml2 libxslt 时我收到警告,它可能会干扰 nokogiri 安装?

             yves$ brew install libxml2 libxslt
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/libxml2-2.9
######################################################################## 100.0%
==> Pouring libxml2-2.9.1.mavericks.bottle.1.tar.gz
==> Caveats
This formula is keg-only, so it was not symlinked into /usr/local.

Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

LDFLAGS: -L/usr/local/opt/libxml2/lib
CPPFLAGS: -I/usr/local/opt/libxml2/include

接下来我应该做什么?谢谢你的建议

最佳答案

几周前我遇到了同样的错误。我是这样解决的:

您必须手动安装损坏的库。使用Homebrew ,这是 OS X 的包管理器。请确保先更新 brew update,然后安装库:

brew install libxml2 libxslt
brew link libxml2 libxslt

您可能需要从源代码安装libiconv:

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

然后您应该能够安装 gem。

引用自此处的文档: http://nokogiri.org/tutorials/installing_nokogiri.html#homebrew_09

安装库后,您可能还需要运行 rbenv rehash

关于ruby-on-rails - Rails 无法安装 nokogiri w Mavericks 和 rbenv,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24856096/

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