MeCabをつかう時はGemfileだけじゃなくてDockerfileにapt-getを書く

掲題のとおりです。

Gemfile

gem 'mecab'
$ docker-compose build

これだけだとエラーが出ます

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /usr/local/bundle/gems/mecab-0.996/ext/mecab
/usr/local/bin/ruby -I /usr/local/lib/ruby/2.7.0 -r
./siteconf20201120-9-14icbml.rb extconf.rb
checking for make… yes
*** 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.

Dockerfile

RUN apt-get install libmecab2 libmecab-dev mecab mecab-ipadic mecab-ipadic-utf8 mecab-utils

これを追記して

$ docker-compose build

おわり

公開日