Please tell me how to deploy the Sinatra app using MeCab to Heroku.

Asked 2 years ago, Updated 2 years ago, 80 views

There was a similar question, but there was no answer, so I would like to ask you a question.

As the title suggests, we are trying to deploy the Sinatra app using MeCab to Heroku.

local PC:Mac OSX

$heroku-v
I put it in heroku/7.6.0 darwin-x64 node-v10.6.0 #homebrew

$ruby-v
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]

$gem list | grep sinatra
sinatra (2.0.3, 2.0.2)

$mecab-v
I put it in mecab of 0.996#homebrew

Heroku OS: Ubuntu

$herokurunbash
$ cat/etc/lsb-release 
DISTRIB_ID = Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.4 LTS"
source "https://rubygems.org"
gem "sinatra"
gem "sinatra-contrib"
gem "mecab", "0.996"
gem "natto"
gem "pry"
$heroku buildpacks
=== mecab-on-sinatra Buildpack URLs
1. https://github.com/heroku/heroku-buildpack-ruby.git
2. https://github.com/diasks2/heroku-buildpack-mecab.git
extconf.rb:12:in``:No such file or directory-mecab-config (Errno::ENOENT)
    from extconf.rb:12:in `<main>'
Error occurred while installing mecab (0.996), and Bundler cannot continue.
Make sure that `gem install mecab-v'0.996' `successes before bundling.

   In Gemfile:
     mecab
$herokurunbash

I tried gem install mecab-v'0.996' by entering heroku's bash, but there was no permission. When I turned on sudo, the sudo command was not found...

How can I resolve these and deploy the app?Please let me know.

ruby ubuntu heroku mecab sinatra

2022-09-30 15:39

1 Answers

Sorry for the long sentence.

It is different from the questioner's environment, but the following combinations are considered to be the minimum configuration.For your information.

 mecab_on_heroku// any directory name
  ├-- .gitignore
  ├-- Gemfile
  ├-- Gemfile.lock
  ├-- Procfile
  └-- app.rb

.gitignore

/vendor

Gemfile

ruby "2.3.7"
source 'https://rubygems.org'
gem'sinatra'
gem 'mecab', '0.996'

Procfile

web:ruby app.rb

app.rb

require'sinatra'
require 'mecab'

get'/'do
  str="We aliens came to invade the earth."
  tagger=MeCab::Tagger.new
  "#{tagger.parse(str)}"
end

Gemfile.lock is created by saving the Gemfile and then executing the following command:

Executing Commands for Generating Gemfile.lock

$bundle install --path vendor/bundle
$cd mecab_on_heroku#Any working directory
$ heroku create-a heroku_app_name --buildpack\
    https://github.com/diasks2/heroku-buildpack-mecab.git
$ heroku config:set LD_LIBRARY_PATH=/app/vendor/mecab/lib

After creating the above five files, deploy them by executing the following command:

$git add.
$ git commit-m "first commit."
$ git push heroku master

The following command automatically opens the default browser to access the Sinatra app:

$heroku open

Tagged question appears.title="View questions tagged with 'mecab'">mecab


2022-09-30 15:39

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.