charlock_holmes: Unable to install 0.7.5 on macOS Sierra 10.12.6

My command:

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

Output:

Building native extensions with: '--with-icu-dir=/usr/local/opt/icu4c'
This could take a while...
ERROR:  Error installing charlock_holmes:
	ERROR: Failed to build gem native extension.

    current directory: /usr/local/lib/ruby/gems/2.4.0/gems/charlock_holmes-0.7.5/ext/charlock_holmes
/usr/local/opt/ruby/bin/ruby -r ./siteconf20170831-19095-1crbzog.rb extconf.rb --with-icu-dir=/usr/local/opt/icu4c
checking for -licui18n... yes
checking for -licui18n... yes
checking for unicode/ucnv.h... yes
checking for -lz... yes
checking for -licuuc... yes
checking for -licudata... yes
creating Makefile

current directory: /usr/local/lib/ruby/gems/2.4.0/gems/charlock_holmes-0.7.5/ext/charlock_holmes
make "DESTDIR=" clean

current directory: /usr/local/lib/ruby/gems/2.4.0/gems/charlock_holmes-0.7.5/ext/charlock_holmes
make "DESTDIR="
compiling converter.c
converter.c:23:12: warning: implicit conversion loses integer precision: 'long' to 'int32_t' (aka 'int') [-Wshorten-64-to-32]
        src_len = RSTRING_LEN(rb_txt);
                ~ ^~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.4.1_1/include/ruby-2.4.0/ruby/ruby.h:980:6: note: expanded from macro 'RSTRING_LEN'
     RSTRING_EMBED_LEN(str) : \
     ^~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.4.1_1/include/ruby-2.4.0/ruby/ruby.h:976:6: note: expanded from macro 'RSTRING_EMBED_LEN'
     (long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
converter.c:23:12: warning: implicit conversion loses integer precision: 'long' to 'int32_t' (aka 'int') [-Wshorten-64-to-32]
        src_len = RSTRING_LEN(rb_txt);
                ~ ^~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.4.1_1/include/ruby-2.4.0/ruby/ruby.h:981:28: note: expanded from macro 'RSTRING_LEN'
     RSTRING(str)->as.heap.len)
     ~~~~~~~~~~~~~~~~~~~~~~^~~
2 warnings generated.
compiling encoding_detector.c
encoding_detector.c:183:71: warning: implicit conversion loses integer precision: 'long' to 'int32_t' (aka 'int') [-Wshorten-64-to-32]
                ucsdet_setDeclaredEncoding(detector->csd, RSTRING_PTR(rb_enc_hint), RSTRING_LEN(rb_enc_hint), &status);
                ~~~~~~~~~~~~~~~~~~~~~~~~~~                                          ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.4.1_1/include/ruby-2.4.0/ruby/ruby.h:980:6: note: expanded from macro 'RSTRING_LEN'
     RSTRING_EMBED_LEN(str) : \
     ^~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.4.1_1/include/ruby-2.4.0/ruby/ruby.h:976:6: note: expanded from macro 'RSTRING_EMBED_LEN'
     (long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
encoding_detector.c:183:71: warning: implicit conversion loses integer precision: 'long' to 'int32_t' (aka 'int') [-Wshorten-64-to-32]
                ucsdet_setDeclaredEncoding(detector->csd, RSTRING_PTR(rb_enc_hint), RSTRING_LEN(rb_enc_hint), &status);
                ~~~~~~~~~~~~~~~~~~~~~~~~~~                                          ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.4.1_1/include/ruby-2.4.0/ruby/ruby.h:981:28: note: expanded from macro 'RSTRING_LEN'
     RSTRING(str)->as.heap.len)
     ~~~~~~~~~~~~~~~~~~~~~~^~~
encoding_detector.c:232:71: warning: implicit conversion loses integer precision: 'long' to 'int32_t' (aka 'int') [-Wshorten-64-to-32]
                ucsdet_setDeclaredEncoding(detector->csd, RSTRING_PTR(rb_enc_hint), RSTRING_LEN(rb_enc_hint), &status);
                ~~~~~~~~~~~~~~~~~~~~~~~~~~                                          ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.4.1_1/include/ruby-2.4.0/ruby/ruby.h:980:6: note: expanded from macro 'RSTRING_LEN'
     RSTRING_EMBED_LEN(str) : \
     ^~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.4.1_1/include/ruby-2.4.0/ruby/ruby.h:976:6: note: expanded from macro 'RSTRING_EMBED_LEN'
     (long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
encoding_detector.c:232:71: warning: implicit conversion loses integer precision: 'long' to 'int32_t' (aka 'int') [-Wshorten-64-to-32]
                ucsdet_setDeclaredEncoding(detector->csd, RSTRING_PTR(rb_enc_hint), RSTRING_LEN(rb_enc_hint), &status);
                ~~~~~~~~~~~~~~~~~~~~~~~~~~                                          ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/ruby/2.4.1_1/include/ruby-2.4.0/ruby/ruby.h:981:28: note: expanded from macro 'RSTRING_LEN'
     RSTRING(str)->as.heap.len)
     ~~~~~~~~~~~~~~~~~~~~~~^~~
4 warnings generated.
compiling ext.c
compiling transliterator.cpp
In file included from transliterator.cpp:5:
In file included from /usr/local/opt/icu4c/include/unicode/translit.h:25:
In file included from /usr/local/opt/icu4c/include/unicode/unistr.h:33:
/usr/local/opt/icu4c/include/unicode/char16ptr.h:90:19: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
    Char16Ptr() = delete;
                  ^
/usr/local/opt/icu4c/include/unicode/char16ptr.h:198:24: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
    ConstChar16Ptr() = delete;
                       ^
In file included from transliterator.cpp:5:
In file included from /usr/local/opt/icu4c/include/unicode/translit.h:25:
/usr/local/opt/icu4c/include/unicode/unistr.h:3025:7: error: delegating constructors are permitted only in C++11
      UnicodeString(ConstChar16Ptr(text)) {}
      ^~~~~~~~~~~~~
/usr/local/opt/icu4c/include/unicode/unistr.h:3087:7: error: delegating constructors are permitted only in C++11
      UnicodeString(ConstChar16Ptr(text), length) {}
      ^~~~~~~~~~~~~
/usr/local/opt/icu4c/include/unicode/unistr.h:3180:7: error: delegating constructors are permitted only in C++11
      UnicodeString(Char16Ptr(buffer), buffLength, buffCapacity) {}
      ^~~~~~~~~~~~~
transliterator.cpp:101:60: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int32_t' (aka 'int') [-Wshorten-64-to-32]
  trans = Transliterator::createInstance(UnicodeString(id, id_len), UTRANS_FORWARD, p_error, status);
                                         ~~~~~~~~~~~~~     ^~~~~~
transliterator.cpp:106:34: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int32_t' (aka 'int') [-Wshorten-64-to-32]
  u_txt = new UnicodeString(txt, txt_len);
              ~~~~~~~~~~~~~      ^~~~~~~
4 warnings and 3 errors generated.
make: *** [transliterator.o] Error 1

make failed, exit code 2

Gem files will remain installed in /usr/local/lib/ruby/gems/2.4.0/gems/charlock_holmes-0.7.5 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0/charlock_holmes-0.7.5/gem_make.out

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Reactions: 24
  • Comments: 25

Most upvoted comments

Only this works for me:

sudo gem install charlock_holmes -- --with-icu-dir=/usr/local/opt/icu4c --with-cxxflags=\'-Wno-reserved-user-defined-literal -std=c++11\'

Can you install gem setting manually c flags?

gem install charlock_holmes -- --with-cxxflags=-std=c++11

Having a similar issue with the official release of High Sierra (10.13.0) and the system installed Ruby 2.3.0, except it’s also having issues with the Ruby Frameworks’s config.h header which appears to conflict with a c++11 standard and errors out:

compiling transliterator.cpp
In file included from transliterator.cpp:1:
In file included from ./common.h:9:
In file included from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby.h:33:
In file included from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/ruby.h:24:
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin17/ruby/config.h:368:31:
error: invalid suffix on literal; C++11 requires a space between literal and
identifier [-Wreserved-user-defined-literal]
#define RUBY_ARCH "universal-"RUBY_PLATFORM_OS
                              ^
                               
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin17/ruby/config.h:369:35:
error: invalid suffix on literal; C++11 requires a space between literal and
identifier [-Wreserved-user-defined-literal]
#define RUBY_PLATFORM "universal."RUBY_PLATFORM_CPU"-"RUBY_PLATFORM_OS
                                  ^
                                   
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin17/ruby/config.h:369:55:
error: invalid suffix on literal; C++11 requires a space between literal and
identifier [-Wreserved-user-defined-literal]
#define RUBY_PLATFORM "universal."RUBY_PLATFORM_CPU"-"RUBY_PLATFORM_OS
                                                      ^
                                                       
3 errors generated.
make: *** [transliterator.o] Error 1

I fixed it by running:

bundle config build.charlock_holmes --with-icu-dir=/usr/local/opt/icu4c --with-cxxflags=\'-Wno-reserved-user-defined-literal -std=c++11\'

before installing the bundle that required charlock_holmes 0.7.5 (GitLab CE), which suppressed the error and got it building properly. Hope this helps someone in the future!

I just ran into this issue while I was attempting to reinstall 0.7.3 after upgrading my computer to the High Sierra GM candidate (10.3 Beta).

Was fixed when I ran:

gem install charlock_holmes -v '0.7.3' -- --with-icu-dir=/usr/local/opt/icu4c --with-cxxflags=-std=c++11

This finally worked and allowed me to install charlock_holmes and run node/npm and run my rails server

brew uninstall icu4c --force --ignore-dependencies
brew cleanup # YMMV, be careful here if you like to keep multiple versions of certain brews
brew reinstall node # forces latest icu4c to be installed
gem install charlock_holmes --version 0.7.6 -- --with-icu-dir=/usr/local/opt/icu4c --with-cxxflags=-std=c++11

edit: this doesn’t solve the OPs issue as it’s 0.7.6 instead of 0.7.5, but it’s the only configuration that seems to work for me on OS X High Sierra 10.13.3

@Weakky One can also work around outdated headers in Ruby by using e.g.

gem install charlock_holmes -- --with-icu-dir=/opt/local --with-cxxflags=-Wno-reserved-user-defined-literal

I’ve patched Ruby master to avoid the need to introduce such spaces in future. https://github.com/ruby/ruby/commit/07f2062c8ffecc774a4ebc1f39ff2c4940592be4

In case it can help:

I was having the following error when running:

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

Building native extensions with: '--with-icu-dir=/usr/local/opt/icu4c --with-cxxfla
gs=-std=c++11'
This could take a while...
ERROR:  Error installing charlock_holmes:
        ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.3.0/gems/charlock_holmes-0.7.6/ext/char
lock_holmes
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -I /Library/Rub
y/Site/2.3.0 -r ./siteconf20191008-51558-13w2yvj.rb extconf.rb --with-icu-dir\=/usr
/local/opt/icu4c --with-cxxflags\=-std\=c\+\+11
checking for main() in -licui18n... yes
checking for main() in -licui18n... yes
checking for unicode/ucnv.h... yes
checking for main() in -lz... yes
checking for main() in -licuuc... yes
checking for main() in -licudata... yes
creating Makefile

current directory: /Library/Ruby/Gems/2.3.0/gems/charlock_holmes-0.7.6/ext/charlock
_holmes
make "DESTDIR=" clean

current directory: /Library/Ruby/Gems/2.3.0/gems/charlock_holmes-0.7.6/ext/charlock
_holmes
make "DESTDIR="
compiling converter.c
compiling encoding_detector.c
compiling ext.c
compiling transliterator.cpp
In file included from transliterator.cpp:1:
In file included from ./common.h:9:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby.h:33:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/ruby.h:24:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin18/ruby/config.h:365:31: error: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wreserved-user-defined-literal]
#define RUBY_ARCH "universal-"RUBY_PLATFORM_OS
                              ^
                               
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin18/ruby/config.h:366:35: error: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wreserved-user-defined-literal]
#define RUBY_PLATFORM "universal."RUBY_PLATFORM_CPU"-"RUBY_PLATFORM_OS
                                  ^
                                   
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin18/ruby/config.h:366:55: error: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wreserved-user-defined-literal]
#define RUBY_PLATFORM "universal."RUBY_PLATFORM_CPU"-"RUBY_PLATFORM_OS
                                                      ^
                                                       
In file included from transliterator.cpp:1:
In file included from ./common.h:9:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby.h:33:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/ruby.h:1988:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/intern.h:47:19: warning: 'register' storage class specifier is deprecated and incompatible with C++17 [-Wdeprecated-register]
void rb_mem_clear(register VALUE*, register long);

I fixed it by manually editing config.h and adding space between literals and identifiers

Before

#define RUBY_ARCH "universal-"RUBY_PLATFORM_OS
#define RUBY_PLATFORM"universal."RUBY_PLATFORM_CPU"-"RUBY_PLATFORM_OS

After

#define RUBY_ARCH "universal-" RUBY_PLATFORM_OS
#define RUBY_PLATFORM "universal." RUBY_PLATFORM_CPU "-" RUBY_PLATFORM_OS

I had the same problem. 0.7.4 worked for me, but 0.7.3 and 0.7.5 did not. ¯\_(ツ)_/¯

Solution for me was to set it in bundler so the config stayed set:

$ brew install icu4c
$ bundle config build.charlock_holmes --with-icu-dir=/usr/local/opt/icu4c --with-cxxflags=-std=c++11
$ bundle

I was able to install 0.7.6 fine under High Sierra 10.3.6 with Ruby 2.4.4 via RVM, but trying to install it against the system Ruby (2.3.7p456) fails with:

ERROR:  Error installing charlock_holmes:
	ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.3.0/gems/charlock_holmes-0.7.6/ext/charlock_holmes
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20180726-54665-1wlohkx.rb extconf.rb --with-icu-dir=/usr/local/opt/icu4c --with-cxxflags=-std=c++11
checking for main() in -licui18n... yes
checking for main() in -licui18n... yes
checking for unicode/ucnv.h... yes
checking for main() in -lz... yes
checking for main() in -licuuc... yes
checking for main() in -licudata... yes
creating Makefile

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-17/2.3.0/charlock_holmes-0.7.6/mkmf.log

current directory: /Library/Ruby/Gems/2.3.0/gems/charlock_holmes-0.7.6/ext/charlock_holmes
make "DESTDIR=" clean

current directory: /Library/Ruby/Gems/2.3.0/gems/charlock_holmes-0.7.6/ext/charlock_holmes
make "DESTDIR="
compiling converter.c
compiling encoding_detector.c
compiling ext.c
compiling transliterator.cpp
In file included from transliterator.cpp:1:
In file included from ./common.h:9:
In file included from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby.h:33:
In file included from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/ruby.h:24:
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin17/ruby/config.h:368:31: error: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wreserved-user-defined-literal]
#define RUBY_ARCH "universal-"RUBY_PLATFORM_OS
                              ^
                               
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin17/ruby/config.h:369:35: error: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wreserved-user-defined-literal]
#define RUBY_PLATFORM "universal."RUBY_PLATFORM_CPU"-"RUBY_PLATFORM_OS
                                  ^
                                   
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin17/ruby/config.h:369:55: error: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wreserved-user-defined-literal]
#define RUBY_PLATFORM "universal."RUBY_PLATFORM_CPU"-"RUBY_PLATFORM_OS
                                                      ^
                                                       
3 errors generated.
make: *** [transliterator.o] Error 1

make failed, exit code 2

I get the same error with or without specifying --with-icu-dir and --with-cxflags. It’s not a dealbreaker since I rarely use the system Ruby and only wanted to suppress some errors I was getting on Emacs startup, but it might indicate some other problem.

I was finally able to get around this by downgrading my icu4c install as suggested at https://github.com/brianmario/charlock_holmes/issues/117#issuecomment-347267575. Once that was done gem install charlock_holmes --version 0.7.5 -- --with-icu-dir=/usr/local/opt/icu4c --with-cxxflags=-std=c++11 installed without issue.

Use the following command : gem install charlock_holmes – --with-icu-dir=/opt/local/

Please give 0.7.6 a try.

… and this is why people stop using C++. 😂

(Just teasing. C++ is a wonderful language, all things considered.)