Gem::Ext::BuildError: ERROR: Failed to build gem native extension unicode.c:1058:20: [-Wincompatible-function-pointer-types]
Asked Answered
U

4

7

Some details about my environment:

  • Ruby version: ruby 3.2.0
  • RubyGems version: 3.5.6
  • rbenv version: 1.2.0
  • MacOS: Sonoma 14.1.2 / M2

I'm trying to run bundle install to install the gems for my project but I'm getting the following error:

Installing unicode 0.4.4.4 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/john.doe/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/unicode-0.4.4.4/ext/unicode
/Users/john.doe/.rbenv/versions/3.2.0/bin/ruby -I /Users/john.doe/.rbenv/versions/3.2.0/lib/ruby/site_ruby/3.2.0 extconf.rb --with-cflags\=-Wno-error\=implicit-function-declaration
creating Makefile

current directory: /Users/john.doe/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/unicode-0.4.4.4/ext/unicode
make DESTDIR\= sitearchdir\=./.gem.20240308-48017-ak1bt1 sitelibdir\=./.gem.20240308-48017-ak1bt1 clean

current directory: /Users/john.doe/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/unicode-0.4.4.4/ext/unicode
make DESTDIR\= sitearchdir\=./.gem.20240308-48017-ak1bt1 sitelibdir\=./.gem.20240308-48017-ak1bt1
compiling unicode.c
unicode.c:37:7: warning: 'RB_OBJ_TAINTED' is deprecated: taintedness turned out to be a wrong idea. [-Wdeprecated-declarations]
  if (OBJ_TAINTED(src))
      ^
/Users/john.doe/.rbenv/versions/3.2.0/include/ruby-3.2.0/ruby/internal/fl_type.h:151:25: note: expanded from macro 'OBJ_TAINTED'
#define OBJ_TAINTED     RB_OBJ_TAINTED     /**< @old{RB_OBJ_TAINTED} */
                        ^
/Users/john.doe/.rbenv/versions/3.2.0/include/ruby-3.2.0/ruby/internal/fl_type.h:118:30: note: expanded from macro 'RB_OBJ_TAINTED'
#define RB_OBJ_TAINTED       RB_OBJ_TAINTED
                             ^
/Users/john.doe/.rbenv/versions/3.2.0/include/ruby-3.2.0/ruby/internal/fl_type.h:812:1: note: 'RB_OBJ_TAINTED' has been explicitly marked deprecated here
RBIMPL_ATTR_DEPRECATED(("taintedness turned out to be a wrong idea."))
^
/Users/john.doe/.rbenv/versions/3.2.0/include/ruby-3.2.0/ruby/internal/attr/deprecated.h:36:53: note: expanded from macro 'RBIMPL_ATTR_DEPRECATED'
# define RBIMPL_ATTR_DEPRECATED(msg) __attribute__((__deprecated__ msg))
                                                    ^
unicode.c:38:5: warning: 'RB_OBJ_TAINT' is deprecated: taintedness turned out to be a wrong idea. [-Wdeprecated-declarations]
    OBJ_TAINT(obj);
    ^
/Users/john.doe/.rbenv/versions/3.2.0/include/ruby-3.2.0/ruby/internal/fl_type.h:149:25: note: expanded from macro 'OBJ_TAINT'
#define OBJ_TAINT       RB_OBJ_TAINT       /**< @old{RB_OBJ_TAINT} */
                        ^
/Users/john.doe/.rbenv/versions/3.2.0/include/ruby-3.2.0/ruby/internal/fl_type.h:116:30: note: expanded from macro 'RB_OBJ_TAINT'
#define RB_OBJ_TAINT         RB_OBJ_TAINT
                             ^
/Users/john.doe/.rbenv/versions/3.2.0/include/ruby-3.2.0/ruby/internal/fl_type.h:843:1: note: 'RB_OBJ_TAINT' has been explicitly marked deprecated here
RBIMPL_ATTR_DEPRECATED(("taintedness turned out to be a wrong idea."))
^
/Users/john.doe/.rbenv/versions/3.2.0/include/ruby-3.2.0/ruby/internal/attr/deprecated.h:36:53: note: expanded from macro 'RBIMPL_ATTR_DEPRECATED'
# define RBIMPL_ATTR_DEPRECATED(msg) __attribute__((__deprecated__ msg))
                                                    ^
unicode.c:1039:20: error: incompatible function pointer types passing 'VALUE (get_categories_param *)' (aka 'unsigned long (struct _get_categories_param *)') to parameter of type 'VALUE (*)(VALUE)' (aka 'unsigned long (*)(unsigned long)') [-Wincompatible-function-pointer-types]
  return rb_ensure(get_categories_internal, (VALUE)&param,
                   ^~~~~~~~~~~~~~~~~~~~~~~
/Users/john.doe/.rbenv/versions/3.2.0/include/ruby-3.2.0/ruby/internal/iterator.h:425:25: note: passing argument to parameter 'b_proc' here
VALUE rb_ensure(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*e_proc)(VALUE), VALUE data2);
                        ^
unicode.c:1040:20: error: incompatible function pointer types passing 'VALUE (WString *)' (aka 'unsigned long (struct _WString *)') to parameter of type 'VALUE (*)(VALUE)' (aka 'unsigned long (*)(unsigned long)') [-Wincompatible-function-pointer-types]
                   get_categories_ensure, (VALUE)&wstr);
                   ^~~~~~~~~~~~~~~~~~~~~
/Users/john.doe/.rbenv/versions/3.2.0/include/ruby-3.2.0/ruby/internal/iterator.h:425:62: note: passing argument to parameter 'e_proc' here
VALUE rb_ensure(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*e_proc)(VALUE), VALUE data2);
                                                             ^
unicode.c:1057:20: error: incompatible function pointer types passing 'VALUE (get_categories_param *)' (aka 'unsigned long (struct _get_categories_param *)') to parameter of type 'VALUE (*)(VALUE)' (aka 'unsigned long (*)(unsigned long)') [-Wincompatible-function-pointer-types]
  return rb_ensure(get_categories_internal, (VALUE)&param,
                   ^~~~~~~~~~~~~~~~~~~~~~~
/Users/john.doe/.rbenv/versions/3.2.0/include/ruby-3.2.0/ruby/internal/iterator.h:425:25: note: passing argument to parameter 'b_proc' here
VALUE rb_ensure(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*e_proc)(VALUE), VALUE data2);
                        ^
unicode.c:1058:20: error: incompatible function pointer types passing 'VALUE (WString *)' (aka 'unsigned long (struct _WString *)') to parameter of type 'VALUE (*)(VALUE)' (aka 'unsigned long (*)(unsigned long)') [-Wincompatible-function-pointer-types]
                   get_categories_ensure, (VALUE)&wstr);
                   ^~~~~~~~~~~~~~~~~~~~~
.
.
.
2 warnings and 6 errors generated.
make: *** [unicode.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/john.doe/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/unicode-0.4.4.4 for inspection.
Results logged to /Users/john.doe/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/extensions/arm64-darwin-23/3.2.0/unicode-0.4.4.4/gem_make.out

  /Users/john.doe/.rbenv/versions/3.2.0/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:102:in `run'
  /Users/john.doe/.rbenv/versions/3.2.0/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:51:in `block in make'
  /Users/john.doe/.rbenv/versions/3.2.0/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:43:in `each'
  /Users/john.doe/.rbenv/versions/3.2.0/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:43:in `make'
  /Users/john.doe/.rbenv/versions/3.2.0/lib/ruby/site_ruby/3.2.0/rubygems/ext/ext_conf_builder.rb:42:in `build'
  /Users/john.doe/.rbenv/versions/3.2.0/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:170:in `build_extension'
  /Users/john.doe/.rbenv/versions/3.2.0/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:204:in `block in build_extensions'
  /Users/john.doe/.rbenv/versions/3.2.0/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:201:in `each'
  /Users/john.doe/.rbenv/versions/3.2.0/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:201:in `build_extensions'
  /Users/john.doe/.rbenv/versions/3.2.0/lib/ruby/site_ruby/3.2.0/rubygems/installer.rb:843:in `build_extensions'
  /Users/john.doe/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/bundler-2.5.6/lib/bundler/rubygems_gem_installer.rb:76:in `build_extensions'
  /Users/john.doe/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/bundler-2.5.6/lib/bundler/rubygems_gem_installer.rb:28:in `install'
  /Users/john.doe/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/bundler-2.5.6/lib/bundler/source/rubygems.rb:205:in `install'
  /Users/john.doe/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/bundler-.
.
.
An error occurred while installing unicode (0.4.4.4), and Bundler cannot continue.

I would really appreciate any help that you can provide. Thanks.

  • I tried "xcode-select --install" to check if there was something missing
  • I've tried with asdf version manager to check if the issue was related to rbenv
Unkenned answered 8/3 at 19:38 Comment(7)
In the project folder, with correct Ruby enabled by rbenv, can you try this command? gem install unicode -- -Wno-incompatible-function-pointer-typesSwimming
I get this error when I try this command: ERROR: Error installing unicode: ERROR: Failed to build gem native extension. current directory: /Users/john.doe.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/unicode-0.4.4.4/ext/unicode /Users/john.doe/.rbenv/versions/3.2.0/bin/ruby -I /Users/john.doe/.rbenv/versions/3.2.0/lib/ruby/3.2.0 extconf.rb --with-cflags\=-Wno-incompatible-function-pointer-types mkmf.rb can't find header files for ruby at /Users/john.doe/.rbenv/versions/3.2.0/lib/ruby/include/ruby.hUnkenned
hmm, I'm not sure where that ruby.h path comes from, in my system is is /Users/mike/.rbenv/versions/3.2.0/include/ruby-3.2.0/ruby.h and should be the same for youSwimming
Can you try giving us output of ruby -rrbconfig -e 'puts RbConfig::CONFIG["rubyhdrdir"]'? You can also try running sudo xcode-select --switch /Library/Developer/CommandLineTools but if you use XCode it can mess something up that I'm not familiar withSwimming
ideas lifted from here, but don't just copy paste everything into your terminal ;) #20559755Swimming
Thanks for your help @MikeSzyndel, I reinstalled ruby and running gem install unicode -- -Wno-incompatible-function-pointer-types solved the issueUnkenned
I’m glad it worked, but still wonder what was the actual issueSwimming
A
12

Use this:

gem install unicode -- --with-cflags="-Wno-incompatible-function-pointer-types"

Ambur answered 11/3 at 13:33 Comment(3)
I get this error when I try this command: ERROR: Error installing unicode: ERROR: Failed to build gem native extension. current directory: /Users/john.doe.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/unicode-0.4.4.4/ext/unicode /Users/john.doe/.rbenv/versions/3.2.0/bin/ruby -I /Users/john.doe/.rbenv/versions/3.2.0/lib/ruby/3.2.0 extconf.rb --with-cflags\=-Wno-incompatible-function-pointer-types mkmf.rb can't find header files for ruby at /Users/john.doe/.rbenv/versions/3.2.0/lib/ruby/include/ruby.hUnkenned
I reinstalled Ruby and ran this command again. The issue got solved. Thanks!Unkenned
Maybe a good idea to add it to your bundler config file, when using bundler: bundle config build.unicode --with-cflags="-Wno-incompatible-function-pointer-types"Suzysuzzy
P
4

I was running into this same issue today after installing the newest Sonoma 14.4 (M1 Chip).

I was able to to resolve this with the suggested:

gem install unicode -- --with-cflags="-Wno-incompatible-function-pointer-types"

Then I could finish out the bundler with

bundle install
Pizarro answered 12/3 at 2:38 Comment(0)
D
-2

Check if this helps. Similar issue is pointed out here

https://github.com/blackwinter/unicode/issues/4

Dislodge answered 9/3 at 15:3 Comment(2)
This link is absolutely unrelated to the questionSwimming
Seems similar, but this is more recent: github.com/blackwinter/unicode/pull/11Pearle
S
-3

You may find this useful: https://bugs.ruby-lang.org/issues/19403

In my case, I just decided to use ruby 3.2.3

Sourwood answered 10/3 at 10:19 Comment(5)
What does this link has to do with the question?Swimming
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Subscript
related to: ` Failed to build gem native extension.` error The posted link above is from this thread: github.com/rbenv/ruby-build/discussions/2123 -Sourwood
Gems can fail to build for a number of reasons. It's absolutely unrelated. Please read the error message carefully before posting wrong answers.Swimming
This doesn't seem related to the problem.Pearle

© 2022 - 2024 — McMap. All rights reserved.