LoginSignup
1
0

More than 5 years have passed since last update.

ruby nokogiriのインストールエラー

Last updated at Posted at 2019-04-11

Nokogiri嫌い

Ubuntu ruby2.5 ( rbenv利用 )

今回の(いつもの)Nokogiriインストール時のエラーです(抜粋)

$ bundle install --path vendor/bundle
...
Fetching nokogiri 1.10.2
Installing nokogiri 1.10.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

ERROR: cannot discover where libxml2 is located on your system. please make sure `pkg-config` is installed.

An error occurred while installing nokogiri (1.10.2), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.10.2' --source 'https://rubygems.org/'` succeeds before bundling.

参考にしました

Installing Nokogiri
https://nokogiri.org/tutorials/installing_nokogiri.html

Ubuntu 14.04 LTSにnokogiriインストール失敗する時
https://qiita.com/ozy-san/items/0eb6c0a88a4cf8acc0ca

今回対処したこと

色々インストール

sudo apt install -y libxml2-dev libxml2 libxslt1.1 libc6-dev libc6 
sudo apt install -y build-essential patch zlib1g-dev libxslt1-dev

pkg-config のインストール

aptでインストール

# エラーに書いてある gem install pkg-config を行なっても改善しなかった
sudo apt install pkg-config

ruby2.5-devの利用(たぶん不要)

# sudo apt~ だとダメだった。rootユーザで実行
sudo su -
apt install -y autoconf bison
edit
rbenv install 2.5.0-dev
rbenv global 2.5.0-dev
gem install bundler

システムライブラリの利用

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

成功

色々やって、うまくいきました。

sudo apt install -y build-essentialsudo apt install pkg-config あたりが重要と思います。

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