以下の内容はhttps://takuya-1st.hatenablog.jp/entry/2018/10/19/070000より取得しました。


ruby - mecab をインストールするときにエラーが出たのでメモ

mecab - ruby を使いたい

久しぶりにmecab をインストールしようとしたら・・・

bundle add mecab 

エラーになるんですね。

extconf.rb:12:in ``': No such file or directory - mecab-config

mecab は extconf で外部ライブラリ(.h)を参照するので、 mecabのインストールが必要でした。

エラーの原因:mecab が未インストールでした。

わたしは、macOS なので brew install します。

takuya@$ brew info mecab
mecab: stable 0.996 (bottled)
Yet another part-of-speech and morphological analyzer
https://taku910.github.io/mecab/
Conflicts with:
  mecab-ko (because both install mecab binaries)
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/mecab.rb

ああ、not installed だ。ずいぶん長い間使ってなかったんですね。つまりMacにしてから数年間一度もmacで使ってないわけだ。

mecab 本体のインストール

brew install mecab
brew install mecab-ipadic

これでインストールは完了

ruby mecab のインストール

bundle add mecab

無事終了しました。

Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Using bundler 1.16.2
Fetching mecab 0.996
Installing mecab 0.996 with native extensions
Using romkan 0.4.0
Bundle complete! 2 Gemfile dependencies, 3 gems now installed.
Bundled gems are installed into `./vendor/bundle`

起動テストをします。

動かしてみます。

require 'mecab'
m = MeCab::Tagger.create("-Ochasen")
puts m.parse ("shachou")
bundle exec ruby sample.rb 
shachou shachou shachou 名詞-固有名詞-組織              
EOS

オッケ。

gem install でシステムに依存しない extconf にしてくれたら嬉しいんだけどなぁ。




以上の内容はhttps://takuya-1st.hatenablog.jp/entry/2018/10/19/070000より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14