How to set charlock_holmes libicu-dev dependency on Heroku

I use ruby ​​gem charlock_holmes in a Rails 4 application to detect CSV character encodings that I process so that CSV.foreach does not CSV.foreach error.

However, when I try to click on the hero (with gem 'charlock_holmes' in the Gemfile), I get the following error:

 Installing charlock_holmes (0.6.9.4) Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. /tmp/build_e741f6ed-a860-47bf-8c0d-1b678fa0ebeb/vendor/ruby-2.0.0/bin/ruby extconf.rb checking for main() in -licui18n... no checking for main() in -licui18n... no *************************************************************************************** *********** icu required (brew install icu4c or apt-get install libicu-dev) *********** *************************************************************************************** *** 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. Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/tmp/build_e741f6ed-a860-47bf-8c0d-1b678fa0ebeb/vendor/ruby-2.0.0/bin/ruby --with-icu-dir --without-icu-dir --with-icu-include --without-icu-include=${icu-dir}/include --with-icu-lib --without-icu-lib=${icu-dir}/ --with-icui18nlib --without-icui18nlib --with-icui18nlib --without-icui18nlib Gem files will remain installed in /tmp/build_e741f6ed-a860-47bf-8c0d-1b678fa0ebeb/vendor/bundle/ruby/2.0.0/gems/charlock_holmes-0.6.9.4 for inspection. Results logged to /tmp/build_e741f6ed-a860-47bf-8c0d-1b678fa0ebeb/vendor/bundle/ruby/2.0.0/gems/charlock_holmes-0.6.9.4/ext/charlock_holmes/gem_make.out An error occurred while installing charlock_holmes (0.6.9.4), and Bundler cannot continue. Make sure that `gem install charlock_holmes -v '0.6.9.4'` succeeds before bundling. 

How do I install libicu-dev to install on Heroku?

+6
source share
4 answers

Unfortunately, the other two solutions do not 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 heroku-buildpack-apt is required to export the BUNDLE_BUILD__CHARLOCK_HOLMES variable via Heroku ENV_DIRs . In the Gemfile, you simply specify gem 'charlock_holmes' as usual, and now everything works smoothly for me.

If anyone can think of a method that is not related to exporting BUNDLE_BUILD__CHARLOCK_HOLMES , then please let me know!


The answer to Ryan’s question doesn’t work for me - Heroku is vouching because the package installation step does not offer any output for 3 minutes. Silas answers refer to frederick/heroku-buildpack-ruby buildpack, which is no longer supported and lags behind the official heroku-buildpack-ruby by a sufficient amount, which is unacceptable to me.

+2
source

Try using the gem "charlock_holmes_bundle_icu", "~> 0.6.9.2" . Additional Information.

+13
source

EDIT June 2017: As the usual one-time packages for this unique problem seem to be outdated, I would recommend trying the approach presented by Benji in this answer . Use heroku-buildpack-multi and heroku-buildpack-apt with Aptfile to specify dependencies.

Steve Tooke also has an excellent review on this very topic: http://tooky.co.uk/using-charklock_holmes-on-heroku/ - note that things may have changed in 3 years since this one was asked question, but you need to remember that generic / supported, and not specific / unsupported, is the best way to work with buildpacks.

Original answer:

While Ryan's answer works, he also slows down the deployment time to my tests - up to 15 minutes. I even came across several times the deployment interval of Heroku.

A simpler solution (which does not affect deployment time) is to use Heroku buildpack

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

Steps to get it working (Copied from Aaron's comment for posterity):

  • Install the CLI buildpack: heroku plugins:install https://github.com/heroku/heroku-buildpacks
  • Install buildpack in the fork of Aaron heroku buildpacks:set frederick/heroku-buildpack-ruby -a myapp
  • In your Gemfile use: gem 'charlock_holmes'
+11
source

It works:

Run the following commands and install this:

1. brew install erlang icu4c spidermonkey

2.brew ln icu4c

This will install the necessary dependencies and then try to set charlock_homes.
-2
source

Source: https://habr.com/ru/post/954298/


All Articles