nokogiri가 설치되지 않을때 대처법
rbenv 를 시스템와이드 하게 설정 한후 테스트환경에 rails를 설치하려고 하자,
이번엔 또 다른 문제에 직면하게 되었다.
nokogiri 가 안깔림
이번 포스트는 rbenv 를 시스템와이드하게 설정한후
nokogiri 안깔리는 경우 대처법에 대해 간단히 포스팅해본다.
참고로 이전문제 :
rbenv 설정 하다 SecurityError 뜰경우 대처법
nokogiri 설치에 앞서 필요한 라이브러리를 설치하자.
- libxml2-devel
- libxslt-devel
CentOS 의 경우
sudo yum install libxml2-devel libxslt-devel
Ubuntu 의 경우
sudo apt-get install libxml2 libxml2-dev libxslt libxslt-dev
에러로그를 확인해보자
Installing nokogiri 1.6.7.1 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. . . 생략 . Team Nokogiri will keep on doing their best to provide security updates in a timely manner, but if this is a concern for you and want to use the system library instead; abort this installation process and reinstall nokogiri as follows: gem install nokogiri -- --use-system-libraries [--with-xml2-config=/path/to/xml2-config] [--with-xslt-config=/path/to/xslt-config] If you are using Bundler, tell it to use the option: bundle config build.nokogiri --use-system-libraries bundle install Note, however, that nokogiri is not fully compatible with arbitrary versions of libxml2 provided by OS/package vendors.
쭉나오는데 보면
gem 인스톨로 할경우
gem install nokogiri -- --use-system-libraries
bundle 커멘드로 인스톨할경우
bundle config build.nokogiri --use-system-libraries bundle install
이렇게 하면 된다고 하는거 같다.
* 참고로 나는 전자 방식으로 설치하였다.
Gemfile 에 system libraries 를 설정 추가
Rails 프로젝트 소스 Gemfile 을 수정하자.
source 'https://rubygems.org' ENV['NOKOGIRI_USE_SYSTEM_LIBRARIES'] = 'YES' . .
이렇게 삽질을 완료하였다.
“rbenv 시스템와이드하게 설정하면서 삽질 시리즈”
를 만들어야 할거 같다.
참고 :
nokogiri インストール時のエラー Running ‘patch’ for libxml2 2.8.0… ERROR
No Comments