Programming

libiconv가 없어서 Mac OS에서 Nokogiri 설치가 실패하는 이유는 무엇입니까?

procodes 2020. 6. 9. 22:35
반응형

libiconv가 없어서 Mac OS에서 Nokogiri 설치가 실패하는 이유는 무엇입니까?


Mac OS 10.9.3에 Nokogiri를 설치하려고하는데 시도한 결과에 관계없이 다음 오류 메시지와 함께 설치가 실패합니다.

$ sudo gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib
Building native extensions with: '--with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib'
This could take a while...
Building nokogiri using packaged 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 --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib
Building nokogiri using packaged libraries.
checking for iconv.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
checking for libiconv_open() in iconv.h... no
checking for libiconv_open() in -liconv... no
-----
libiconv is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** 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
    --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


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/gems/nokogiri-1.6.2.1/ext/nokogiri/gem_make.out

" Nokogiri 설치 "에 설명 된대로 소스에서 brew 및 libiconv 빌드를 사용하여 libxml2 및 libxslt 빌드 및 설치를 포함하여 웹에서 많은 도움을 얻은 후에도 오류는 동일하게 유지됩니다.

Nokogiri에 대한 설치를 실행하려고 할 때 libxml2 및 libxslt는 잘 보이지만 libiconv는 아닙니다.

이러한 것들에 대해 잘 알고있는 사람이라면 누구나 노코 기리 설치 방법을 알고 있습니까?


나는 같은 문제가 있었다. 불행히도 " Nokogiri 설치 "에는 Iconv 문제가 포함되지 않습니다. 문제를 해결하는 방법은 다음과 같습니다.

먼저 homebrew를 설치 하면 인생을 더 편하게 할 수 있습니다. 이미 설치 한 경우 다음과 같이 업데이트하여 최신 수식을 가져와야합니다.

brew update

참고 : OSX 10.9 이상에서는 libiconv를 설치할 수 있도록 xCode 명령 도구를 설치해야 할 수도 있습니다.

xcode-select --install

그런 다음 최신 버전의 libiconv를 설치하십시오.

brew install libiconv

그런 다음 새 iconv 라이브러리를 연결하십시오.

brew link libiconv

그런 다음 보석을 설치하십시오

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

시스템 라이브러리를 사용해보십시오. OSX는 최신 버전의 libiconv와 함께 제공되지만 기본 설치 스크립트에 문제가있는 것 같습니다

gem install nokogiri -- --use-system-libraries

편집 : Geoff가 언급 한 번 들러를 사용하는 경우 다음을 수행 할 수 있습니다.

bundle config build.nokogiri --use-system-libraries

@Cory의 솔루션에는 정답이 포함되어 있지만 Mavericks의 솔루션은 실제로 최상위 솔루션보다 훨씬 간단하므로 필요한 단계만으로 다시 게시하고 있습니다.

매버릭스 (OSX 10.9+) :

Xcode 명령 행 도구를 설치하십시오.

xcode-select --install

그런 다음 보석을 설치하십시오.

gem install nokogiri

마침내이 문제를 해결할 수있었습니다. 위의 해결책 중 어느 것도 나를 위해 완전히 고치지 않았습니다.

gem install nokogiriOSX Lion 10.7.2에서 시도 할 때이 오류가 발생했습니다 . 우선,이 오류는 nokogiri가 libxslt 또는 libxml2를 찾을 수 없어도 동일한 오류가 발생하기 때문에 libiconv가 누락되었다고 말함으로써 실제 문제를 숨 깁니다.

그래서 나는 Homebrew 섹션 ( http://nokogiri.org/tutorials/installing_nokogiri.html) 의 지침을 따랐습니다 (현재 최신 버전의 libxml2를 설명하기 위해 약간 수정되었습니다).

brew install libxml2
brew link libxml2

# install libxslt from source
wget ftp://xmlsoft.org/libxml2/libxslt-1.1.26.tar.gz
tar -zxvf libxslt-1.1.26.tar.gz
cd libxslt-1.1.26
./configure --prefix=/usr/local/Cellar/libxslt/1.1.26 --with-libxml-prefix=/usr/local/Cellar/libxml2/2.7.8
make
sudo make install

이 시점에서 나는 노코 기리 사이트의 지시에 따라 시도했다

gem install nokogiri -- --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26

그러나 소스에서 libxslt를 빌드 할 때 /include폴더가 펑키 한 장소에 설치되기 때문에 여전히 실패했습니다 . 따라서 다음 libinclude같이 폴더를 별도로 지정해야합니다 .

gem install nokogiri -- --with-xslt-lib=/usr/local/Cellar/libxslt/1.1.26/lib --with-xslt-include=/usr/local/Cellar/libxslt/1.1.26/include/libxslt

이것은 여전히 ​​작동하지 않으므로 (동일한 libiconv 오류) 세 개의 필수 라이브러리 (libxslt, libxml2 및 libiconv)를 모두 지정하려고했습니다.

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

이제 다른 오류가 발생했습니다! 여전히 오류이지만 적어도 다릅니다. make 프로세스가 실패했습니다 :

in /opt/local/lib/libz.1.dylib, file was built for unsupported file format which is not the architecture being linked (x86_64) for architecture x86_64

어? 많은 인터넷 검색 후, 나는이 기적의 게시물을 보았습니다 : http://www.refresherate.com/2010/01/08/fixing-ld-warning-in-usrlocalliblibz-dylib-file-is-not-of-required -건축물/

분명히 OSX Lion은 일부 나쁜 버전의 libz 라이브러리 ( libz.dylib, libz.1.dylib, libz.1.2.4.dylib)와 함께 제공되며 Xcode SDK의 최신 버전으로 바꿔야합니다. 이 기사는 내가 할 수있는 것보다 더 잘 설명하므로 특정 지침은 위의 링크를 읽으십시오.

이것들이 교체되면, 나는 달렸다

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

다시 모든 것이 잘되었습니다. 나는 이것이 다른 누군가를 돕기를 바랍니다.


군중에게 내 목소리를 추가하기 만했지만 mkmf.log는 x86_64 아키텍처의 심볼을 찾을 수 없다는 내용을 말했습니다. 이 솔루션을 우연히 발견했습니다.

sudo env ARCHFLAGS="-arch x86_64" gem install nokogiri -- --use-system-libraries

원래의 아수를 위해 아무것도 해결하지 못할 수도 있지만, 이것은 누군가를 도울 수 있습니다.

참고 : nokogiri는 루비 애플리케이션 사용에있어 가장 높은 장벽이었습니다. 누군가 다른 버전에 의존 할 때마다 그것을 빌드하는 방법을 알아야합니다. 그리고 제 문제는 매번 다릅니다.


사용하고 있습니다 .. OS X 10.9.4 Homebrew 0.9.4

이 스레드에서 nokogiri를 성공적으로 설치하고 누락 된 libiconv를 수정하는 내 여름이 있습니다.

Homebrew http://brew.sh/를 설치 하거나 아래 명령을 사용하여 최신으로 업데이트하십시오

brew update

libxml2 libxslt 설치

brew install libxml2 libxslt

libxml2 libxslt를 모두 링크

brew link libxml2 libxslt

--force를 사용하라는 경고가 표시되면 아래 명령을 사용하십시오.

brew link --force libxml2 libxslt

libiconv를 설치할 수 있도록 xCode 명령 도구를 설치하십시오.

xcode-select --install

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 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

나는 이것을 Yosemite실행 Ruby 2.1.4하여 해결 했다.

  1. xCode 6.1이 설치되어 있는지 확인한 다음
  2. xcode-select --install그런 다음
  3. 앱 스토어에서 클릭 업데이트 하고 명령 줄 도구의 최신 버전을 설치합니다 (이 분명히 xcode-select --installdoes't 할 - 한숨)
  4. 그런 다음 bundle install정상적으로 작동했습니다.

나는 또한 brew install libiconv너무했지만 단계가 필요하다고 확신하지 않습니다.


나는 많은 것을 시도했지만 아무것도 나를 위해 일하지 않았다. 그런 다음 iconv 설명서를 마침내 찾았고 하루를 절약했습니다!


mkmf 파일을 보면 nokogiri (또는 gem, 모르겠다)가 / op / local /에서 종속성을 찾으려고 시도합니다. 나에게는 그것들을 찾는 올바른 길이 아닙니다.

nokogiri가 올바른 위치에서 라이브러리를 찾도록 강요하면 (홈브류를 사용합니다)

$ gem install nokogiri -- --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 --with-xml2-dir=/usr/local/Cellar/libxml2/2.7.8/

노코 기리에서 고칠 수있는 것이 있을지도 모릅니다.

HTH,


libiconv는 Homebrew 0.9에서 제거되었습니다. 이제 소스에서 libiconv를 컴파일 한 다음 nokogiri gem을 설치할 때 설치를 참조하는 것이 좋습니다. Nokogiri 설치 페이지 의 Homebrew 0.9 섹션에서 Nokogiri 설치 지침을 참조하십시오.


gem의 빌드 디렉토리에서 mkmf.log 파일을 확인하십시오 (예 : /Library/Ruby/Gems/1.8/gems/nokogiri-1.4.4/ext/nokogiri/mkmf.log). 더 많은 정보가 있습니다. 필자의 경우, Nokogiri는 라이브러리 검색 경로에 / opt / local / lib를 추가하고 GNU Backgammon은 호환되지 않는 libiconv를 설치했습니다.


MacPorts와 함께 libxml2 및 libxslt를 설치했다고 가정하면 have_func ( 'iconv_open', 'iconv.h') 호출에 사용되는 포함 경로 및 링크 경로 순서가 일치하지 않아서이 오류가 계속 발생합니다.

간단한 (패치) 솔루션 : / usr / local / lib에서 libiconv. * 삭제


$ gem install nokogiri -- --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 --with-xml2-dir=/usr/local/Cellar/libxml2/2.7.8/

위와 동일하게 홈 브루 및 gem 설치를위한 솔루션입니다 (버전에 따라 변경 사항이 적용됨)

그러나 Gemfile 및 번들 설치를 사용하는 경우 설치하기 전에 번들 구성을 적용해야합니다 (여기 코드).

$ bundle config build.nokogiri --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 --with-xml2-dir=/usr/local/Cellar/libxml2/2.7.8/ --with-iconv-dir=/usr/local/Cellar/libiconv/1.14

다시, 변경 사항을 적용하는 것은 버전에 따라 다릅니다

이것이 도움이되기를 바랍니다.

크레딧 : https://gist.github.com/1344331


Mountain Lion에서도 비슷한 문제가있었습니다. 이전에 rvm 패키지를 통해 libiconv를 설치했으며 ruby ​​1.9.3 / Mountain Lion / nokogiri에는 더 이상 필요하지 않습니다.

https://rvm.io/packages/ 의 조언에 따라 $ rvm_path / usr 디렉토리를 삭제하고 루비 1.9.3을 다시 빌드했습니다. 그 후 노코 기리 설치는 단순한 보석 설치였습니다. brew / macports / manual source installs와 혼동하지 마십시오!


매버릭스 에서이 작업을 수행 할 수도 있습니다.

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

xcode가 설치되어 있는지 확인하십시오.


나는 OS X 10.10 Yosemite에서 오늘 노코 기리와 잠시 싸웠습니다.

어떤 이유로 내 환경이 엉망이되었습니다.

which bundle그리고 which gem저를 포기했다 /usr/bin/bundle/usr/bin/gem대신~/.rbenv/shims/gem

나를 수정하는 데 도움이 된 것은 sudo rm -i /usr/bin/gem /usr/bin/bundle

1. 종속 3. (재) 제거 내 프로젝트 디렉토리 2로 다시 전환 종속 libs와 -installed : 나는 것으로는 후했다 brew install libxml2 libiconv libxslt4. 5.했다 (rbenv와) 내 루비 버전의 신선한 설치 gem install bundler(6)과 bundle install어떤없이 달렸다 문제.

Nokogiri 그 후 괜찮 았습니다.

참고로 :

╰─% cat .bundle/config           
---
BUNDLE_PATH: vendor/bundle
BUNDLE_DISABLE_SHARED_GEMS: '1'
BUNDLE_JOBS: 4

╰─% which ruby bundle gem
~/.rbenv/shims/ruby
~/.rbenv/shims/bundle
~/.rbenv/shims/gem

홈브류를 0.9로 업그레이드해야합니다

다음 단계를 따르십시오

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.9.0/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.0/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib

폴더 라이브러리 버전을 다시 확인해야합니다.


HOMEBREW 사용자

homebrew를 사용하는 경우이 문제를 해결하기위한 올바른 솔루션 :

xcode-select --install

대화 상자에서 "Get Xcode"를 선택하십시오.

brew unlink libiconv
gem install nokogiri

xcode-select 단계는 Xcode 설치 및 Xcode Command Line Utils 설치를 수정합니다. O / S 업그레이드 또는 백업에서 복원하는 데 문제가있어 /usr/include/iconv.h가 없다는 것을 알았습니다. xcode-select를 실행 한 후 해당 헤더 파일과 /usr/lib/libconv.dylib가 없으면 Xcode를 응용 프로그램 폴더에서 휴지통으로 끌어다 놓고 다시 설치 한 다음 Xcode 용 명령 줄 도구를 수동으로 다운로드해야합니다 에서 https://developer.apple.com/downloads/index.action 과하면 해당를 설치합니다.

그런 다음 homebrew에서 libiconv를 연결 해제해야합니다. 당신은 이것을 필요로하지 않습니다. clang은 실제로 /usr/include/iconv.h에서 /usr/local/include/iconv.h를 선택하고 #iconv_open을 libiconv_open으로 정의하지만 libiconv_open이없는 /usr/lib/libiconv.dylib에 대해 링크합니다. mkmf가 libiconv를 찾지 못하는 원인입니다. 당신이해야 할 일은 nokogiri가 그것을 찾을 수 없도록 iconv.h의 링크를 제거하는 것입니다.

그런 다음 정상적으로 노코 기리를 만드십시오.

신규 사용자의 경우 xcode-select를 사용하여 xcode를 설치하고 nokogiri를 설치하기 만하면되지만,이 질문을 찾은 경우 Mavericks를 새로 설치하지 않고 설치가 완료된 것 같습니다.

여기에있는 다른 답변 중 일부는 분명히 틀립니다. 그들 대부분은 완전히 불필요하게 양조장에서 libiconv를 사용하려고 시도합니다. brew link libiconv실제로 clang이 혼란스러워서 homebrew 헤더 파일을 읽고 시스템 라이브러리에 연결하려고 시도하는 문제를 실제로 일으키는 답변 . --use-system-librariesnokogiri가 번들로 제공되는 libxml2 및 libxslt 라이브러리와 링크되어야하므로 다른 버전의 라이브러리와 호환되지 않기 때문에 제안한 대답 은 좋지 않습니다. 소스에서 컴파일하려는 답변은 절망적으로 지나치게 복잡합니다.

TL; DR :

  • Xcode 설치 업그레이드 및 / 또는 수리
  • 문제를 야기하는 사용을 시도한 후 homebrew libiconv 연결을 해제하십시오
  • 정상적으로 노코 기리를 건설하십시오

RVM 사용자

이전 RVM 설치는 시스템 라이브러리와 충돌하는 rvm 디렉토리에 libiconv가 숨겨져있을 수 있습니다. 자세한 내용은 https://stackoverflow.com/a/11809261/506908 을 참조하십시오.

MacPorts 사용자

/opt/local/lib/libiconv.dylib를 사용하는 경우 nokogiri는 검색 한 디렉토리 목록에 해당 경로를 추가하고 홈 브루 크 libiconv를 선택하고 시스템 라이브러리와 충돌하는 방식과 유사한 MacPorts 설치를 찾습니다. 당신은 시도 할 수 있습니다:

sudo port uninstall libiconv

종속성으로 인해 실패하면 MacPorts 버전과 직접 연결해보십시오 (예상치 않음).

gem install nokogiri -- --with-iconv-dir=/opt/local

이것은 나를 위해 일했다

sudo env ARCHFLAGS = "-arch x86_64"gem 설치 nokogiri : 1.6.6.2---use-system-libraries --with-xml = / usr / local / Cellar / libxml2 / 2.9.3 / --with-iconv- dir = / usr / local / Cellar / libiconv / 1.14


gem install nokogiri -v '1.6.6.2' -- --use-system-libraries --with-xml2-include=$(brew --prefix libxml2)/include/libxml2

this worked for me on macos


I ran into this, this morning... after an upgrade to Mavericks. We did many things. However if anyone is having this issue here are some things to try.

I ran 'xcode-select --install' then got the command line tools installed (surprised this didn't update on the OS ugrade). I ran 'rvm implode' (I will build it back up later).

We pieced together two error output files:

~/.vagrant.d/gems/gems/nokogiri-1.6.3.1/ext/nokogiri/gem_make.out

~/.vagrant.d/gems/gems/nokogiri-1.6.3.1/ext/nokogiri/tmp/x86_64-apple-darwin12.5.0/ports/libxml2/2.8.0/configure.log

Which seemed to indicate that the c compiler was using a surprising setting.

I ran 'env'

Output contained:

...
CXX=/usr/local/opt/apple-gcc42/bin/g++-4.2
...
CC=/usr/local/opt/apple-gcc42/bin/gcc-4.2
...

These files didn't exist on the file system...

After all of these changes moving to a new terminal windows (so everything was fresh). Installation of vagrant-berkshelf (which in turn installs nokogiri) worked fine.

NOTE: when running 'env' in the fresh window there was no longer a setting for CC or CXX...

Unsure on the key part of this, or if order matters, but tried to recreate the parts that seemed to play a role in getting this to work.


According to the documentation, as of OSX 10.9 and Homebrew 9.5+, you are probably missing the development tools.

Nokogiri installation

Troubleshooting

If you have problems mentioning libiconv missing that looks something like this:

Installing nokogiri (1.6.2.1) Building nokogiri using packaged libraries.

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /usr/local/rvm/rubies/ruby-2.0.0-p0/bin/ruby extconf.rb
Building nokogiri using packaged libraries.
checking for iconv.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
checking for libiconv_open() in iconv.h... no
checking for libiconv_open() in -liconv... no
-----
libiconv is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for          help with installing dependencies.
-----
*** extconf.rb failed ***

Then you are probably missing the right developer tools. This is a really easy fix:

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

This is verified working on OSX 10.9 w/ xcode’s clang compiler.


I got this issue when I upgraded my Mac OS to Yosemite. I was able to solve this issue by doing:

xcode-select --install
brew uninstall libiconv
brew install libiconv
gem install nokogiri

I had a similar issue and the accepted answer used to work for me. Now, however I have been seeing a new error message where a gmkdir command is missing as in this question:

gem install nokogiri -v '1.5.11' failed due to make: /usr/local/bin/gmkdir: No such file or directory

What worked for me was first a little cleanup:

brew uninstall libiconv
brew uninstall libxml2
brew uninstall libxslt

And then brew unlink libiconv and whatever else you need to unlink (check with brew doctor). Then, the magic two lines (copied from the linked answer):

brew install coreutils
gem install nokogiri

Simple steps to follow before you start uninstalling and installing anything. Check if you have CLT (command line tools installed):

brew config

see the CLT version here if its installed no need for reinstallation.

This means the issue is with permission you have reinstall only bundler gem make its not sudo. Uninstall bundler with gem uninstall bundler reinstall gem bundler gem install bundler

Most important point here is the permission under which bundler gem is installed it should never be sudoed.


First of all make sure you follow the installation guide on nokogiri: http://nokogiri.org/tutorials/installing_nokogiri.html

After having followed the guide I still had this issue. This is how I solved it:

First of all I installed iconv using homebrew: brew install iconv

Then I uninstalled ruby, luckily this is very easy with rvm:

rvm uninstall 1.9.2        

Then I had to reinstall ruby with the following options:

CC=gcc-4.2 rvm install 1.9.2-p290 --with-iconv-dir=/usr/local/Cellar/libiconv/1.13.1

Then I create a gemset with the new ruby version:

rvm use 1.9.2@coolproject

Then I can finally install nokogiri like this:

gem install nokogiri -v=1.4.4 -- --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

In my case, (as with scotchi) the build failed because of an incompatible iconv library in /opt/local/lib. By default, theNokogiri build process looks at /opt/local first. To force it to use a different install directory, /usr/local for example, do:

gem install nokogiri -- --with-xml2-lib=/usr/local/lib --with-xml2-include=/usr/local/include/libxml2 --with-xslt-lib=/usr/local/lib --with-xslt-include=/usr/local/include

This blog post proposes to install libiconv manually.

Subsequently, nokogiri can be installed with a number of switches telling it where to find libiconv (see the blog post).

As a side note: After installing nokogiri, I managed to install gollum (installation of which also failed because it could not find iconv). Now I am still facing problems though, because when I start up gollum, Python crashes.


$ gem install iconv # works but it is missing an iconv.so file in ruby 2.0.0-p247

$ ls -1 2.0.0-p0/lib/ruby/gems/2.0.0/gems/iconv-1.0.3/*/*/*.so
2.0.0-p0/lib/ruby/gems/2.0.0/gems/iconv-1.0.3/ext/iconv/iconv.so*
2.0.0-p0/lib/ruby/gems/2.0.0/gems/iconv-1.0.3/lib/iconv/iconv.so*

$ ls -1 2.0.0-p247/lib/ruby/gems/2.0.0/gems/iconv-1.0.3/*/*/*.so
2.0.0-p247/lib/ruby/gems/2.0.0/gems/iconv-1.0.3/ext/iconv/iconv.so*

NOTE THE MISSING /lib/iconv/iconv.so file in 2.0.0-p247 that is present in 2.0.0-p0 gems installation.

$ rbenv version
2.0.0-p247 (set by /home/XXX/tmp/.ruby-version)
$ rbenv which gem
/home/XXX/.rbenv/versions/2.0.0-p247/bin/gem
$ gem --version
1.8.25

$ rbenv which pry
/home/XXX/.rbenv/versions/2.0.0-p247/bin/pry
$ pry
[1] pry(main)> require 'iconv'
LoadError: cannot load such file -- iconv/iconv.so
from /home/XXX/.rbenv/versions/2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:36:in `require'

Copy the file over

$ pushd ~/.rbenv/versions/
$ cp 2.0.0-p247/lib/ruby/gems/2.0.0/gems/iconv-1.0.3/ext/iconv/iconv.so 2.0.0-p247/lib/ruby/gems/2.0.0/gems/iconv-1.0.3/lib/iconv/

NOW IT WORKS!

$ pry
[1] pry(main)> require 'iconv'
=> true

I had to install gcc first before running ./configure --prefix=/usr/local/Cellar/libiconv/1.13.1

참고URL : https://stackoverflow.com/questions/5528839/why-does-installing-nokogiri-on-mac-os-fail-with-libiconv-is-missing

반응형