“安装charlock_holmes时出错”:“icu required”

时间:2013-06-18 01:08:58

标签: ruby

我正在尝试在我的Mac上安装charlock_holmes(10.7.5,ruby-1.9.3-p392),我遇到以下错误:

$gem install charlock_holmes -v '0.6.9.4'
Building native extensions.
This could take a while...
ERROR:  Error installing charlock_holmes:
ERROR: Failed to build gem native extension.

/Users/mthompson/.rvm/rubies/ruby-1.9.3-p392/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.

我已经通过macport安装了icu,所以我的icu目录是/opt/local/lib/icu/opt/local/share/icu。我尝试使用指定的目录进行安装:

$ gem install charlock_holmes -v '0.6.9.4' -- --with-icu-dir=/opt/local/lib/icu --with-opt-include=/usr/local/include/ --with-opt-lib=/usr/local/lib/

..但是我遇到了同样的错误。任何想法都会受到欢迎。

3 个答案:

答案 0 :(得分:11)

我可以使用安装了macports的ICU版本安装此gem,并将--with-opt-include--with-opt-lib指向/opt的子目录。

通过运行成功安装gem:

gem install charlock_holmes -v '0.6.9.4' -- --with-icu-dir=/opt/local/lib/icu --with-opt-include=/opt/local/include/ --with-opt-lib=/opt/local/lib/

答案 1 :(得分:5)

我今天遇到了这个问题。我意识到通过切换到Homebrew解决了原始问题。这对我来说不是一个可以接受的解决方案,所以我一直在挖掘。解决方案实际上非常简单。

通过Macports安装icu后,只需运行:

即可安装charlock_holmes

gem install charlock_holmes -- --with-icu-dir=/opt/local

希望这有助于遇到此问题的其他人,并且不愿意放弃Macport来解决它。

答案 2 :(得分:2)

我最终从MacPorts切换到Homebrew并重新安装我的红宝石和包。