LoginSignup
0
0

More than 5 years have passed since last update.

zshでpre-commitを導入する際の注意点

Posted at

はじめに

個人開発でpre-commitを導入したのですが、zshに切り替えてからというものの、


Could not find nokogiri-1.8.5 in any of the sources
Run `bundle install` to install missing gems.

というエラーに悩まされたので、解決方法を記します。

解決方法

git configに設定を追加


$ git config pre-commit.ruby "bundle exec ruby"

まずはpre-commitの公式サイトに基づいて、上記のコマンドを実行する。

libxml2をbrewでいれ、シンボリックリンクを削除

$ brew install libxml2
$ brew unlink libxml2

1.1. libxml2とは
libxml2とは、XMLを解析・操作するC言語のライブラリです。
xmlsoft(http://www.xmlsoft.org/)で配布されています。

rbenvの再設定

$ rbenv exec gem install bundler
$ rbenv rehash
$ bundle install

bundlerの再設定

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

今回のキモはここで、systemのlibrariesにあるnokogiriを使うように指定してあげれば良かったようですね。

参考サイト

bundle install で nokogiri をインストールしろと言われる解決方法

Homebrewメモ

libxml2

Bundlerでビルドオプションを指定する

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