Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/65.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 on rails 捆绑包安装时Nokogiri出现错误(OSx Mavericks)_Ruby On Rails_Ruby_Gem_Nokogiri - Fatal编程技术网

Ruby on rails 捆绑包安装时Nokogiri出现错误(OSx Mavericks)

Ruby on rails 捆绑包安装时Nokogiri出现错误(OSx Mavericks),ruby-on-rails,ruby,gem,nokogiri,Ruby On Rails,Ruby,Gem,Nokogiri,我是rails新手,我不明白为什么Nokogiri在尝试捆绑安装时不想安装: barnab21:sample_app barnab21$ sudo bundle install Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on thi

我是rails新手,我不明白为什么Nokogiri在尝试捆绑安装时不想安装:

barnab21:sample_app barnab21$ sudo bundle install
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as
root will break this application for all non-root users on this machine.
Fetching gem metadata from http://rubygems.org/.........
Using rake 0.9.6
Using abstract 1.0.0
Using activesupport 3.0.7
Using builder 2.1.2
Using i18n 0.5.4
Using activemodel 3.0.7
Using erubis 2.6.6
Using rack 1.2.8
Using rack-mount 0.6.14
Using rack-test 0.5.7
Using tzinfo 0.3.39
Using actionpack 3.0.7
Using mime-types 1.25.1
Using polyglot 0.3.5
Using treetop 1.4.15
Using mail 2.2.20
Using actionmailer 3.0.7
Using arel 2.0.10
Using activerecord 3.0.7
Using activeresource 3.0.7
Using diff-lcs 1.1.3
Using mini_portile 0.6.0
Building nokogiri using system libraries.

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --use-system-libraries
Building nokogiri using system libraries.
libxml2 version 2.6.21 or later is required!
*** 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
    --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-xml2-dir
    --without-xml2-dir
    --with-xml2-include
    --without-xml2-include=${xml2-dir}/include
    --with-xml2-lib
    --without-xml2-lib=${xml2-dir}/lib
    --with-libxml-2.0-config
    --without-libxml-2.0-config
    --with-pkg-config
    --without-pkg-config
    --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-exslt-dir
    --without-exslt-dir
    --with-exslt-include
    --without-exslt-include=${exslt-dir}/include
    --with-exslt-lib
    --without-exslt-lib=${exslt-dir}/lib
    --with-libexslt-config
    --without-libexslt-config
    --with-pkg-config
    --without-pkg-config

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.2.1 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-13/2.0.0/nokogiri-1.6.2.1/gem_make.out
An error occurred while installing nokogiri (1.6.2.1), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.2.1'` succeeds before bundling.
我试试这个

 $ xcode-select --install
然后安装nogoriki,但这不起作用

我尝试从另一个stackoverflow线程执行此操作

如果以前安装过,请卸载gem:

$ gem uninstall nokogiri
如果需要,请使用自制软件安装libxml2、libxslt和libiconv:

$ brew install libxml2 libxslt libiconv
安装gem,指定要链接到的库的路径:

$ NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install nokogiri -- --use-system-libraries --with-iconv-dir="$(brew --prefix libiconv)" --with-xml2-config="$(brew --prefix libxml2)/bin/xml2-config" --with-xslt-config="$(brew --prefix libxslt)/bin/xslt-config"
以及:

This could take a while...
Building nokogiri using system libraries.
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --use-system-libraries --with-iconv-dir=/usr/local/opt/libiconv --with-xml2-config=/usr/local/opt/libxml2/bin/xml2-config --with-xslt-config=/usr/local/opt/libxslt/bin/xslt-config
Building nokogiri using system libraries.
libxml2 version 2.6.21 or later is required!
*** 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.
我不知道该怎么做。。。谢谢
我的mac电脑:Macbook pro retina 15,mavericks

$brew安装libxml2 libxslt libiconv之后

gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.7.8/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.8/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib

这对我很有用。你可以尝试一下,但可以将库的版本更改为你的版本。

所以我在约塞米蒂,认为这可能会有所帮助。 上面的解决方案对我不起作用,但后来我意识到有几个目录不知何故被移动到了自己的目录中

--with-xml2-include=/usr/local/ceral/libxml2/2.9.2/include/libxml2/libxml

--使用iconv lib=/usr/local/ceral/libiconv/1.14/lib/lib

因此,如果有人仍然存在问题,那么检查所有目录可能是值得的(哈,我不认为我这样放置文件,但这是完全可能的)

我使用的完整命令:

gem安装nokogiri--with-xml2-include=/usr/local/cillar/libxml2/2.9.2/include/libxml2/libxml--with-xml2-lib=/usr/local/cillar/libxml2/2.9.2/lib--xslt-dir=/usr/local/cillar/libxslt/1.1.28--with-iconv-include=/usr/local/cillar/libiconv/lib/1.14/lib--


在Redhat linux 6中遇到同样的问题

您需要安装libxml2&libxml2-devel和libxslt&libxslt-devel软件包

{您需要安装libgcrypt&libgcrpt-devel,因为需要安装上述软件包}

确保安装了最新版本。 如果包已经存在,那么您需要升级这些包。 只用

rpm-uvh--replacefiles{your_packagename.rpm}
希望能有帮助。如果需要更多帮助,请发表评论。

这就是问题所在:
libxml2 2.6.21或更高版本是必需的您需要首先确保它安装在Mac上。Thx我尝试:gem安装nokogiri--with-xml2-include=/usr/local/cillar/libxml2/2.9.1/include/libxml2--with-xml2-lib=/usr/local/cillar/libxml2/2.9.1/lib--with-xslt dir=/usr/local/cillar/cillar/libxslt/1.1.28--with-iconv-include=/usr/local/local/cillar/cillar/libiconv/1.14/include--使用iconv-lib=/usr/local/cillar/libiconv/1.14/lib但不起作用..我总是有相同的错误。你认为我需要改变其他事情吗?我只需更改librariesCheck的版本,在命令中检查所有路径,并确保在此目录中有库。您也可以尝试以下操作:
brew链接libxml2 libxslt libiconv
,但brew必须在安装后链接它。最新的
nokogori
似乎不需要
libiconv
。以下内容在我的例子中起了作用:
gem安装nokogiri-v1.6.1--with-xml2-include=/usr/local/cillar/libxml2/2.9.2/include/libxml2--with-xml2-lib=/usr/local/cillar/libxml2/2.9.2/lib--with-xslt-dir=/usr/local/cillar/libxslt/1.1.28
。检查你的地窖树是否有正确的版本号;当然,替换为您感兴趣的
nokogiri
版本。对我不起作用-我得到:错误:执行gem时。。。(Gem::FilePermissionError)您没有/Library/Ruby/Gems/2.0.0目录的写入权限。德雷吉尔:德比豪斯$