LoginSignup
4
4

More than 5 years have passed since last update.

Mac 上で Ruby の nokogiri 1.6.8 インストールの際に LZMA_OK 識別子が原因でビルドエラーになる時の対応方法

Last updated at Posted at 2016-08-01

現象

nokogiri gem をインストールしようとした際にビルドエラーとなってしまいます。

gem install nokogiri -v '1.6.8'

LZMA がどうのこうの。圧縮系ライブラリがなにかまずいのかもしれません。

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

(中略)

xmlIO.c:1450:52: error: use of undeclared identifier 'LZMA_OK'
    ret =  (__libxml2_xzclose((xzFile) context) == LZMA_OK ) ? 0 : -1;
                                                   ^
1 error generated.
make[2]: *** [xmlIO.lo] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
========================================================================
*** 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.

解決

システムのライブラリを利用するよう変更しましょう。

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

bundler 利用時は、 bundler 経由で nokogiri がインストールされた時の設定を行いましょう。

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

その他解決方法

xz はファイルの圧縮ツールです。
何らかの理由で Homebrew から xz をインストールしてしまっている場合、これをアンインストールします。

brew uninstall xz
gem install nokogiri -v '1.6.8'

参考

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4