Fixing errors installing the charlock_holmes ruby gem

This gem can be a PITA to install on a mac, this is what worked for me. If you get this error:

charlock_holmes -v '0.7.6'
Building native extensions. This could take a while…
ERROR: Error installing charlock_holmes:
ERROR: Failed to build gem native extension.
current directory: /Users/will/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/charlock_holmes-0.7.6/ext/charlock_holmes
/Users/will/.rbenv/versions/2.6.1/bin/ruby -I /Users/will/.rbenv/versions/2.6.1/lib/ruby/2.6.0 -r ./siteconf20190213-34122-e636v8.rb extconf.rb
checking for -licui18n… yes
checking for -licui18n… yes
checking for unicode/ucnv.h… 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:
To see why this extension failed to compile, please check the mkmf.log which can be found here:
extconf failed, exit code 1
Gem files will remain installed in /Users/will/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/charlock_holmes-0.7.6 for inspection.
Results logged to /Users/will/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/charlock_holmes-0.7.6/gem_make.out

view raw
hosted with ❤ by GitHub

First, make sure you have installed the required dependencies:

brew install xz icu4c

Now, install charlock_holmes:

gem install charlock_holmes -v=0.7.6 -- --with-opt-dir=/usr/local/opt --with-opt-include=/usr/local/opt/icu4c/include --with-opt-lib=/usr/local/opt/icu4c/lib --with-cxxflags=-std=c++11

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s