How to install charlock_holmes dependency libicu-dev on Heroku

馋奶兔 提交于 2019-11-30 20:55:19
Benjie

Sadly the other two solutions don't work for me (see below), so I had to come up with my own solution. This solution works with Ruby 1.9.3 but hammady says it does not work with 2.0.0.

I used heroku-buildpack-multi:

heroku config:add BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git

With the following .buildpacks:

https://github.com/benjie/heroku-buildpack-apt
https://github.com/heroku/heroku-buildpack-ruby

And this Aptfile:

libicu-dev

My fork of heroku-buildpack-apt is required to export the BUNDLE_BUILD__CHARLOCK_HOLMES variable via Heroku's ENV_DIRs. In the Gemfile you just reference gem 'charlock_holmes' as usual and all works smoothly now for me.

If anyone can think of a way that doesn't involve exporting BUNDLE_BUILD__CHARLOCK_HOLMES then please let me know!


Ryan's answer doesn't work for me - Heroku bails because the bundle install step doesn't offer any output for 3 minutes. Silasj's answer references the frederick/heroku-buildpack-ruby buildpack which is no longer maintained and lags behind the official heroku-buildpack-ruby by quite an amount, which is not acceptable to me.

Try using gem "charlock_holmes_bundle_icu", "~> 0.6.9.2". More info.

EDIT June 2017: As custom one-off buildpacks for this singular issue seem to go out of date, I'd recommend trying the approach presented by Benjie in this answer. Use heroku-buildpack-multi and heroku-buildpack-apt with an Aptfile to specify dependencies.

Steve Tooke also has an excellent write-up on this very issue: http://tooky.co.uk/using-charklock_holmes-on-heroku/ -- note that things may have changed in the 3 years since this question was asked, but the thing to remember is that generic/supported, rather than specific/unsupported, is the best route to go with buildpacks.

Original Answer:

While Ryan's answer works, it also slows down deploy times to -in my tests- up to 15 minutes. I even ran into Heroku's deploy time limit a few times.

An easier solution (that doesn't affect deploy times), is to use a Heroku buildpack

Aaron Severs created a buildpack that includes icu4c (which charlock_holmes relies on) in the dyno build. [see here]

Steps to make it work (Copied from Aaron's comment for posterity):

  1. Install the buildpack CLI: heroku plugins:install https://github.com/heroku/heroku-buildpacks
  2. Set the buildpack to Aaron's fork heroku buildpacks:set frederick/heroku-buildpack-ruby -a myapp
  3. In your Gemfile, use: gem 'charlock_holmes'

This works:

Execute the following commands and install this:

1. brew install erlang icu4c spidermonkey

2. brew ln icu4c

This will install the required dependencies and then try to install charlock_homes.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!