MacにMastodonの開発環境を構築する際にエラーが発生した。
いくつかのgemがC言語のライブラリに依存しているので、自分でインストールしなければならないようだ。
#環境
Mac OS 10.13
Ruby 2.5.1
Mastodon 2.3.3
#状況
bundle installで下記のエラーが発生。
$ bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching https://github.com/ykzts/devise-two-factor.git
Fetching rake 12.3.1
Installing rake 12.3.1
Installing capistrano-yarn 2.0.2
Fetching xpath 3.0.0
Installing xpath 3.0.0
Fetching capybara 2.18.0
Installing capybara 2.18.0
Fetching charlock_holmes 0.7.6
Installing charlock_holmes 0.7.6 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
/Users/user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/charlock_holmes-0.7.6/ext/charlock_holmes
/Users/user/.rbenv/versions/2.5.1/bin/ruby -r ./siteconf20180420-1825-ayz6nd.rb extconf.rb
checking for -licui18n... no
checking for -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=/Users/user/.rbenv/versions/2.5.1/bin/$(RUBY_BASE_NAME)
--with-icu-dir
--without-icu-dir
--with-icu-include
--without-icu-include=${icu-dir}/include
--with-icu-lib
--without-icu-lib=${icu-dir}/lib
--with-icui18nlib
--without-icui18nlib
--with-icui18nlib
--without-icui18nlib
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/charlock_holmes-0.7.6/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in
/Users/user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/charlock_holmes-0.7.6 for
inspection.
Results logged to
/Users/user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/charlock_holmes-0.7.6/gem_make.out
An error occurred while installing charlock_holmes (0.7.6), and Bundler cannot
continue.
Make sure that `gem install charlock_holmes -v '0.7.6'` succeeds before bundling.
In Gemfile:
charlock_holmes
#解決
homebrewでicu4cをインストールする必要がある。
$ brew install icu4c
私の環境ではさらにcld3とidn-rubyのインストールに失敗したので、下記の通りにインストールした。
$ brew install protobuf
$ brew install libidn
これでbundle installに成功するようになった。