Skip to content

Installing charlock holmes and libicu dev on heroku 18 stack

Donny Kurnia edited this page Apr 10, 2021 · 3 revisions

These instructions assume that you are using Heroku-18 Stack, see here for instructions on how to upgrade if you aren't already using it.

You can use Heroku's built-in support for multiple buildpacks to install and use charlock_holmes.

Assuming you're starting with the default ruby buildpack, you need to add the apt buildpack to top of the stack:

$ heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-apt

After adding the buildpack, your stack should look like this:

$ heroku buildpacks
=== your-heroku-app Buildpack URLs
1. https://github.com/heroku/heroku-buildpack-apt
2. heroku/ruby
$

heroku-buildpack-apt allows you to create an Aptfile which lists packages to install before installing and building gems. The Aptfile should contain the following:

libicu60
libicu-dev

In heroku-18, libicu60 package is already installed but you'll get an error because it's not compiled with -fPIC. Thus the need to reinstall. The libicu-dev package will install both the libicu binaries and header files needed to build charlock_holmes.

There's no need to set any bundler configuration parameters, because the apt buildpack configures the system paths to include the locations of the binaries and include files added via apt.

Using that combination, you can just use the official gem version in your Gemfile:

gem 'charlock_holmes'

That's it!

Credits to Steve Tooke and Mat Brown, see here.