Since mecab is not installed in the Heroku environment, if you simply push it, it will fail in the build.
There were various methods such as heroku-buildpack-mecab
and heroku-buildpack-linuxbrew
, but
The more I looked it up, the more deprecated storms.
The result of trial and error as to whether it can be done with buildpack is the method of using heroku-buildpack-apt
this time.
Record how to build an environment using heroku-buildpack-apt
and heroku-buildpack-ruby
.
--People who want to use gem natto / mecab in Rails / Sinatra environment on Heroku --People who are not familiar with Docker and want to prepare the above environment by a method that does not use Docker
heroku-buildpack-apt
heroku-buildpack-ruby
below, but an unsupported buildpack.
--Although it is ubuntu environment, the file system is locked, so you cannot install packages. This is where it comes in.
--Create a file called ʻAptfile` in the root of the repository and write a list of packages you want to install.heroku-buildpack-ruby
Gemfile Make sure the following gems are installed in the Gemfile
Gemfile
gem 'mecab', '0.996'
gem 'natto'
bash
heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-apt
heroku buildpacks:add --index 2 heroku/ruby
Now you have an environment that uses these two buildpacks. Reference
It is installed under /app/.apt/usr/lib/x86_64-linux-gnu
via buildpack.
mecabrc goes in /app/.apt/etc/mecabrc
.
Go through the path there
bash
heroku config:set MECABRC=/app/.apt/etc/mecabrc
heroku config:set MECABRC=/app/.apt/etc/mecabrc
heroku config:set MECAB_PATH=/app/.apt/usr/lib/x86_64-linux-gnu/libmecab.so
Write the packages you want to be installed on heroku-buildpack-apt
.
Create ʻAptfile` at the root of the repository
Aptfile
mecab
libmecab-dev
mecab-ipadic
mecab-ipadic-utf8
Deploy
bash
git add .
git commit -m 'commit message'
git push heroku master
I did my best with buildpack, but I think it's overwhelmingly peaceful to do it with Docker.