Install Nokogiri 1.6.1 under Ruby 2.0.0p353 (rvm based installation) fails (OSX Mavericks)?

主宰稳场 提交于 2019-11-29 10:26:32

Check your grep version and install latest via brew:

$ grep --version
grep (BSD grep) 2.5.1-FreeBSD

$ brew install grep --default-names

# If above fails, you probably need to tap
$ brew tap homebrew/dupes
$ brew install grep --default-names

$ grep --version
grep (GNU grep) 2.14.56-1e3d

From (this nokogiri issue)[https://github.com/sparklemotion/nokogiri/issues/935]: "recent versions of OSX come with BSD grep, while older ones came with GNU grep. And that, your build script, perhaps requires GNU grep"

Stolen from Maverick's comment and duplicated here as an answer and not a comment because I've now run into this issue several times and would love to save someone else the headache. =X

You can try the solution which I used so far to fix the same...

Remove all older libxml-ruby and nokogiri

use below command for the same

sudo gem uninstall nokogiri libxml-ruby

then you can try out the version of nokogiri, was having issue. THat should works perfect.

sudo gem install nokogiri -v '1.6.1' 

Much similar answer reported by Dan but some little bit change. Thanks.

I wrote a post on this after dealing with it myself. No need for homebrew.

There was a few issues I ran into, the first one being that the development tools cannot be found, and the second one that the libxml is too old.

Run the following commands in the rubyconsole:

$ sudo xcode-select -switch /Library/Developer/CommandLineTools
$ gem uninstall nokogiri libxml-ruby
$ gem install nokogiri

Turned out there is a bit simpler solution:

Remove this line in your ~/.bashrc or ~/.bash_profile file:

GREP_OPTIONS="--color=always"

with this one:

export GREP_OPTIONS="--color=auto"

This way you won't need to install any duplicates. Thanks to MrPowers @ Nokogiri Issues.

manually ./configure 'include' and 'lib' locations helped me out. libxml2 source layout is a bit strange, so i ended up with alike options:

gem install nokogiri -- --use-system-libraries --with-xslt-dir=/usr/local/opt/libxslt --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib

of course, version numbers depend upon what is actually installed. at the time of this writing there version were in the brew.

in my case /usr/local/Cellar/libxml2/2.9.1/include/libxml2 contains a single directory named libxml and /usr/local/Cellar/libxml2/2.9.1/lib contains libxml2.2.dylib libxml2.a libxml2.dylib pkgconfig xml2Conf.sh: these are what the script is looking for, no other combination made it compile using system libraries.

using homebrew nokogiri can be installed with neither outdated nor incompatible (recent) libxml2 and libxslt libraries as pointed out in this gist. working fine and fast for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!