[RUBY] nokogiri install/update 에러 해결하기(An error occurred while installing nokogiri (1.8.2), and Bundler cannot continue.)

간만에 레일즈 떔에 루비 가지고 놀던 중 nokogiri가 고장났습니다. (대체로 부팅과 함께 패키지 업데이트를 하는데, 그게 문제였죠..)

Using debug_inspector 0.0.3
Using i18n 0.9.3
Using tzinfo 1.2.5
The latest bundler is 1.16.1, but you are currently running 1.15.1.
To update, run `gem install bundler`
Downloading nokogiri-1.8.2 revealed dependencies not in the API or the lockfile (mini_portile2 (~> 2.3.0)).
Either installing with `--full-index` or running `bundle update nokogiri` should fix the problem.

단순하게 보면 nokogiri 버전업 중 문제가 있다고 합니다. gem이 준 솔루션대로 업데이트를 진행해보면..

#> bundle update nokogiri

또 에러가 납니다. 대체로 의존성 관련 에러나 패키지 에러들은 물고 물리기 떄문에 가장 깊이 있는 에러를 해결하는게 좋은 대안입니다.

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.8.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.3.0/gems/nokogiri-1.8.2 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.8.2/gem_make.out

An error occurred while installing nokogiri (1.8.2), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.8.2'` succeeds before bundling.

.....

    current directory: /var/lib/gems/2.3.0/gems/nokogiri-1.8.2/ext/nokogiri
/usr/bin/ruby2.3 -r ./siteconf20180303-14226-1i2ac0v.rb extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
Using mini_portile version 2.3.0
checking for gzdopen() in -lz... no
zlib is missing; necessary for building libxml2
*** 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.

잘 읽으면 보입니다. 아래 부분에 zlib 가 없어서 libxml2 빌딩이 안된다고 하네요.

#> apt-get install zlib1g-dev #> bundle update nokogiri

잘 됩니다 :)

혹시 그래도 문제가 있다면..

전체 gem package에 대해 restore 해보세욥.

#> gem pristine –all