programing

OSX 10.10 Yosemite에 Nokogiri 설치

goodcopy 2021. 1. 16. 10:38
반응형

OSX 10.10 Yosemite에 Nokogiri 설치


최근에 10.10 Yosemite 베타로 업그레이드했지만 Nokogiri를 설치하는 데 문제가 있습니다. RVM과 Ruby 1.9.3을 사용하고 있습니다. 나는 또한 여기 의 단계를 따르고 Nokogiri의 홈페이지에있는 지침을 따라 시도했습니다.

homebrew를 통해 libxml2 (2.9.1) 및 libxslt (1.1.28)를 설치했으며 Xcode 5 설치 및 Xcode 6 베타에서 명령 줄 도구를 사용해 보았습니다.

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

        /Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/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.

Provided configuration options:
    --with-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/grantdavis/.rvm/rubies/ruby-1.9.3-p362/bin/ruby
    --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-iconv-dir
    --without-iconv-dir
    --with-iconv-include
    --without-iconv-include=${iconv-dir}/include
    --with-iconv-lib
    --without-iconv-lib=${iconv-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-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-libxml-2.0-config
    --without-libxml-2.0-config
    --with-libiconv-config
    --without-libiconv-config
/Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'
    from /Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:970:in `block in find_header'
    from /Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
    from /Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
    from /Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
    from /Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
    from /Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
    from /Users/grantdavis/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb:969:in `find_header'
    from extconf.rb:114:in `<main>'

누구나 이러한 설치 오류를 수정하는 방법에 대한 아이디어가 있습니까?

6/10/14 수정 : OSX 10.10에 Nokogiri를 설치하기 위해 며칠 동안 시도한 후 작업을 포기하고 내 컴퓨터에서 10.9를 복원했습니다. 10.10 환경에서 작동하려면 여러 라이브러리 및 번들을 업데이트해야합니다.


Yosemite (OS X 10.10 Preview) 아래에 Nokogiri를 설치했습니다.

1 단계 : Brew 설치

Brew가 설치된 경우 이것을 건너 뛰십시오.

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2 단계 : Brew libs 설치

brew tap homebrew/dupes
brew install libxml2 libxslt
brew install libiconv

3 단계 : 10.10 용 Apple 명령 줄 도구 다운로드 및 설치

설치 후 다시 시작해야합니다.

링크 : command_line_tools_for_osx_10_10_june_2014.dmg

다시 시작한 후 터미널에서 설치를 확인할 수 있습니다.

> xcode-select --install
-> xcode-select: error: command line tools are already installed, use "Software Update" to install updates

이 오류는 명령 줄 도구가 올바르게 설치되었음을 의미합니다.

Nokogiri 설치

Gemfile에서 n 이전 버전 1.6.1을 사용해보십시오. 버전 1.6.2.1에는 현재 "10.10 미리보기"에 문제가 있습니다. 내 rbenv Ruby 2.0.0p247에서만 작동하며 2.1.1에 설치하지 못했습니다. 기존 Ruby 버전을 몇 번 시도해 볼 수 있습니다.

gem install nokogiri  -v '1.6.1' -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.14/

libxml2-요세미티의 1.6.6.2 :

sudo env ARCHFLAGS="-arch x86_64" gem install nokogiri -- --use-system-libraries  -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.2/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.2/lib --with-xslt-lib=/usr/local/lib --with-xslt-include=/usr/local/include

Mac OS El Capitan의 경우 :

gem install nokogiri -v '1.6.7.1' -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2


이것은 나를 위해 일했습니다.

ARCHFLAGS="-arch x86_64" gem install nokogiri -v '1.6.0'

MacPorts ruby2.1에서 동일한 문제가 발생했습니다.

can not gem install nokogiri on osx10.10 with macports ruby2.1

설치가 시작되고 CPU가 단일 코어에서 100 %로 50 %가 된 다음 CPU가 거의 0으로 떨어지지 만 iostat tps벽을 통과합니다.

도움이되었습니다.

# port install libiconv libxslt libxml2

# gem install nokogiri -- --use-system-libraries --with-iconv-dir=/opt/local --with-xml2-dir=/opt/local --with-xslt-dir=/opt/local

이것은 마침내 나를 위해 일했습니다.

sudo gem install nokogiri -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib/

El Capitan에서이 작업을 수행 할 수 없었던 다른 사람을 위해 마침내 나를 위해 일한 것은 다음과 같습니다.

sudo gem install nokogiri -- --use-system-libraries --with-xslt-dir=/usr/local/opt/libxslt --with-iconv-dir=/usr/local/opt/libiconv --with-xml2-dir=/usr/local/opt/libxml2 --with-xml2-config=/usr/local/opt/libxml2/bin/xml2-config --with-xml2-include=/usr/local/opt/libxml2/include/libxml2 --with-xslt-config=/usr/local/opt/libxslt/bin/xslt-config

나는 맥 포트를 설치하지 않았고, 내 시스템은 이상하다. 각 종속성에 대해 특정 설치를 강제하는 것이 Nokogiri를 컴파일 할 수있는 유일한 방법입니다. 매우 짜증나지만 적어도 작동합니다.


Nokogiri 웹 사이트 의 지침은 OSX 10.9 및 10.10 모두에서 저에게 효과적이었습니다.

brew unlink gcc-4.2      # you might not need this step
gem uninstall nokogiri
xcode-select --install
gem install nokogiri

sudo gem update --system
sudo gem install nokogiri -v '1.6.6.2' -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib

(여기에 전체 답변 https://gist.github.com/chrisb/4d6a09c6cc1ca2e1b14e )

It looks like Homebrew somehow depends on Ruby being in Versions/1.8 (though even Mavericks ships with 2.0). Until Homebrew addresses this, we'll symlink our system version of Ruby to the one Homebrew looks for.

Create the folder:

sudo mkdir -p /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin

Then symlink the binary:

sudo ln -s /usr/bin/ruby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby

This worked for me:

$ brew install libxml2 libxslt  # optional?
$ brew install libiconv         # optional?
$ gem install nokogiri -v 1.6.8 -- --use-system-libraries --with-xml2-include=/usr/local/opt/libxml2

on environment like this:

$ sw_vers -productVersion 
10.9.4
$ brew -v
Homebrew 0.9.9 (git revision aa747; last commit 2016-05-26)
$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.0.14
  - RUBY VERSION: 2.0.0 (2014-02-24 patchlevel 451) [universal.x86_64-darwin13]

The only thing that worked for me was to upgrade the compiler from apple-gcc42 to gcc48:

brew uninstall apple-gcc42
brew install gcc48 # this might take an hour or so
rvm implode
\curl -sSL https://get.rvm.io | bash -s stable # reinstall RVM
rvm install ruby-1.9.3-p551
bundle update libv8 # 3.16.14.3 doesn't work but 3.16.14.7 does
bundle

If you're using OS X 10.10 and MacPorts you have to install pkgconfig as well:

sudo port install pkgconfig libxml2 libxslt libiconv

Also if you want to use MacPorts libraries automagically without adding configure options you'll need to add this to your .profile or .bashrc:

export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export MANPATH=/opt/local/share/man:$MANPATH
export LDFLAGS="-L/opt/local/lib"
export CPPFLAGS="-I/opt/local/include"

And also you may want to add this to tell Nokogiri to always use your system libraries:

export NOKOGIRI_USE_SYSTEM_LIBRARIES=Y

Restart terminal after adding all these exports.

Using this configuration you can install Nokogiri using:

gem install nokogiri

I got the same error message on OS X Yosemite version 10.10.5

I had recently done various OS updates and it turned out I only needed to accept the new xcode license agreement using the following command:

sudo xcodebuild -license

In my case, the error message was written below and the accordingly solution as well.

Error message:

...
libxml2 is missing.  Please locate mkmf.log to investigate how it is failing.
...

Solution:

gem install nokogiri -- --use-system-libraries --with-libxml2lib=/usr/local/opt/libxml2/lib/libxml2.a

I directly gave it the path of the library of libxml2.a


Install the full Xcode. It was the only thing that worked for me for old Nokogiri versions.


For me switching to Xcode 5 rather than using Xcode 6's CLI tool:

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/

I think the issue is related to the system Ruby not being found or multiple Rubies are installed.

  • Do you use RVM to manage rubies?
  • What is the output of ruby -v?

Those should be the starting point to finding a solution.

The bad interpreter error is related to a problem with the Ruby installation.

Ideally, you should start with the system Ruby, the one that ships with Xcode. So, you would uninstall Xcode completely using:

http://osxdaily.com/2012/02/20/uninstall-xcode/

Uninstall brew, rvm and reinstall them.


Just try:

xcode-select --install

This worked:

gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2 --use-system-libraries

Source


solve the "Can't write /usr/bin/nokogiri while Installing on Mac OS El Capitan" problem on mac os x:

sudo gem install nokogiri -n /usr/local/bin

Reference: https://www.bountysource.com/issues/28085261-can-t-write-usr-bin-nokogiri-while-installing-on-mac-os-ei-capitan


Try this out:

Install these packages in the given order:

brew install libxml2 libxslt
brew link libxml2 libxslt
gem install nokogiri

Try updating gcc version:

ReferenceURL : https://stackoverflow.com/questions/24091869/installing-nokogiri-on-osx-10-10-yosemite

반응형