KAEDE Hack blog

JavaScript 中心に ライブラリなどの使い方を解説する技術ブログ。

Sloved Nokogiri Error by libxml2 libxslt libiconv

RubyのノコギリGemのErrorを解決した

f:id:kei_s_lifehack:20190927011604j:plain

池袋の駆け出しエンジニアもくもく会で 崎山先生にホワイトボードも使って教えて頂いた。

Sakiyama told

NOKOGIRI USING LOWER LAYER!!!!

In Kakedasi Mokumoku pary, https://twitter.com/sakiyamaK taught me.

He said:

scroll the err msg. Then main error found.

ERROR:  Error installing rails:
ERROR: Failed to build gem native extension.
Building Nokogiri with a packaged version of libxml2-2.9.9

libxml2-2.9.9 is the problem He told me to see this

https://qiita.com/tdkn/items/88a2ba7631e118483163

brew install libxml2 libxslt libiconv

Then add PATH of 3:

libxml2

If you need to have libxml2 first in your PATH run: echo 'export PATH="/usr/local/opt/libxml2/bin:$PATH"' >> ~/.bash_profile

For compilers to find libxml2 you may need to set: export LDFLAGS="-L/usr/local/opt/libxml2/lib" export CPPFLAGS="-I/usr/local/opt/libxml2/include"

For pkg-config to find libxml2 you may need to set: export PKG_CONFIG_PATH="/usr/local/opt/libxml2/lib/pkgconfig"

libxslt

To allow the nokogiri gem to link against this libxslt run: gem install nokogiri -- --with-xslt-dir=/usr/local/opt/libxslt

If you need to have libxslt first in your PATH run: echo 'export PATH="/usr/local/opt/libxslt/bin:$PATH"' >> ~/.bash_profile

For compilers to find libxslt you may need to set: export LDFLAGS="-L/usr/local/opt/libxslt/lib" export CPPFLAGS="-I/usr/local/opt/libxslt/include"

For pkg-config to find libxslt you may need to set: export PKG_CONFIG_PATH="/usr/local/opt/libxslt/lib/pkgconfig"

libiconv

If you need to have libiconv first in your PATH run: echo 'export PATH="/usr/local/opt/libiconv/bin:$PATH"' >> ~/.bash_profile

For compilers to find libiconv you may need to set: export LDFLAGS="-L/usr/local/opt/libiconv/lib" export CPPFLAGS="-I/usr/local/opt/libiconv/include"

linking all

brew link --force libxml2 libxslt libiconv

refered

完全版 : nokogiri ビルドエラー時の対処法
https://qiita.com/tdkn/items/88a2ba7631e118483163