LoginSignup
6
7

More than 5 years have passed since last update.

Vagrant上のVMへのmecab-ipadic-neologdのインストールが失敗する時

Posted at

MeCab用のすごい辞書として有名な mecab-ipadic-neologdVagrant上のUbuntuにインストールしようとしたところ、次のようなエラーが発生しました。

(前略)
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
reading ./mecab-user-dict-seed.20170417.csv ... /home/ubuntu/mecab-ipadic-neologd/bin/../libexec/make-mecab-ipadic-neologd.sh: line 492: 2130 Aborted                 (core dumped) ${MECAB_LIBEXEC_DIR}/mecab-dict-index -f UTF8 -t UTF8

std::bad_allocとあるので、どうやらメモリ不足のようですね。
Vagrantfileを編集して、VMに割当るメモリの量を増やしてみましょう。
私は次のようにして4GBを割当ることにしました。(当初1GBにしてみましたが足りませんでした)

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/xenial64"
  config.vm.provider :virtualbox do |vb|
    vb.customize ["modifyvm", :id, "--memory", 4096]
  end
end

Vagrantfileを編集したらvagrant reloadでVMを再起動してvagrant sshでログインしたのちにfree -mhと打ってメモリの空き容量を確認してみます。

              total        used        free      shared  buff/cache   available
Mem:           3.9G         47M        1.3G        5.8M        2.5G        3.6G
Swap:            0B          0B          0B

こんな感じで十分な空きが確保できました。
再び$ ./bin/install-mecab-ipadic-neologd -nと打って、インストールを始めてみます。
すると今度は、

(前略)
[install-mecab-ipadic-NEologd] : Usage of mecab-ipadic-NEologd is here.
Usage:
    $ mecab -d /usr/lib/mecab/dic/mecab-ipadic-neologd ...

[install-mecab-ipadic-NEologd] : Finish..
[install-mecab-ipadic-NEologd] : Finish..

うまくいきました。

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