tonytonyjan / jaro_winkler

Ruby & C implementation of Jaro-Winkler distance algorithm which supports UTF-8 string.
MIT License
195 stars 29 forks source link

Error installing 1.5.4 on macOS #51

Closed mrblrrd closed 1 year ago

mrblrrd commented 1 year ago

Hi! I'm getting an error while installing jaro_winkler-1.5.4 on macOS Ventura 13.3.1

$ gem install jaro_winkler
Building native extensions. This could take a while...
ERROR:  Error installing jaro_winkler:
    ERROR: Failed to build gem native extension.

    current directory: /Users/ruslan/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jaro_winkler-1.5.4/ext/jaro_winkler
/Users/ruslan/.rbenv/versions/3.2.2/bin/ruby extconf.rb
creating Makefile

current directory: /Users/ruslan/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jaro_winkler-1.5.4/ext/jaro_winkler
make DESTDIR\= sitearchdir\=./.gem.20230418-11016-1ihig4 sitelibdir\=./.gem.20230418-11016-1ihig4 clean

current directory: /Users/ruslan/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jaro_winkler-1.5.4/ext/jaro_winkler
make DESTDIR\= sitearchdir\=./.gem.20230418-11016-1ihig4 sitelibdir\=./.gem.20230418-11016-1ihig4
compiling adj_matrix.c
compiling codepoints.c
compiling jaro.c
compiling jaro_winkler.c
jaro_winkler.c:19:3: error: incompatible function pointer types passing 'VALUE (size_t, VALUE *, VALUE)' (aka 'unsigned long (unsigned long, unsigned long *, unsigned long)') to parameter of type 'VALUE (*)(int, union (unnamed union at /Users/ruslan/.rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:271:1), VALUE)' (aka 'unsigned long (*)(int, union (unnamed at /Users/ruslan/.rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:271:1), unsigned long)') [-Wincompatible-function-pointer-types]
  rb_define_singleton_method(rb_mJaroWinkler, "distance",
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/ruslan/.rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:308:143: note: expanded from macro 'rb_define_singleton_method'
#define rb_define_singleton_method(obj, mid, func, arity)   RBIMPL_ANYARGS_DISPATCH_rb_define_singleton_method((arity), (func))((obj), (mid), (func), (arity))
                                                                                                                                              ^~~~~~
/Users/ruslan/.rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:271:1: note: passing argument to parameter here
RBIMPL_ANYARGS_DECL(rb_define_singleton_method, VALUE, const char *)
^
/Users/ruslan/.rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:254:72: note: expanded from macro 'RBIMPL_ANYARGS_DECL'
RBIMPL_ANYARGS_ATTRSET(sym) static void sym ## _m1(__VA_ARGS__, VALUE(*)(int, union { VALUE *x; const VALUE *y; } __attribute__((__transparent_union__)), VALUE), int); \
                                                                       ^
jaro_winkler.c:21:3: error: incompatible function pointer types passing 'VALUE (size_t, VALUE *, VALUE)' (aka 'unsigned long (unsigned long, unsigned long *, unsigned long)') to parameter of type 'VALUE (*)(int, union (unnamed union at /Users/ruslan/.rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:271:1), VALUE)' (aka 'unsigned long (*)(int, union (unnamed at /Users/ruslan/.rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:271:1), unsigned long)') [-Wincompatible-function-pointer-types]
  rb_define_singleton_method(rb_mJaroWinkler, "jaro_distance", rb_jaro_distance,
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/ruslan/.rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:308:143: note: expanded from macro 'rb_define_singleton_method'
#define rb_define_singleton_method(obj, mid, func, arity)   RBIMPL_ANYARGS_DISPATCH_rb_define_singleton_method((arity), (func))((obj), (mid), (func), (arity))
                                                                                                                                              ^~~~~~
/Users/ruslan/.rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:271:1: note: passing argument to parameter here
RBIMPL_ANYARGS_DECL(rb_define_singleton_method, VALUE, const char *)
^
/Users/ruslan/.rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:254:72: note: expanded from macro 'RBIMPL_ANYARGS_DECL'
RBIMPL_ANYARGS_ATTRSET(sym) static void sym ## _m1(__VA_ARGS__, VALUE(*)(int, union { VALUE *x; const VALUE *y; } __attribute__((__transparent_union__)), VALUE), int); \
                                                                       ^
2 errors generated.
make: *** [jaro_winkler.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/ruslan/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jaro_winkler-1.5.4 for inspection.
Results logged to /Users/ruslan/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/extensions/arm64-darwin-22/3.2.0/jaro_winkler-1.5.4/gem_make.out

As you can see I use rbenv. The cause of the error is in incompatible types after macro expansion. But I have no much experience in C to quickly fix it myself. Can you help me please?

/Users/ruslan/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jaro_winkler-1.5.4/ext/jaro_winkler/jaro_winkler.c:19

Screenshot 2023-04-18 at 23 44 20

/Users/ruslan/.rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:254

Screenshot 2023-04-18 at 23 58 00
saxxi commented 1 year ago

Confirmed, same environment, same error here, thanks for reporting

tonytonyjan commented 1 year ago

Thanks for reporting but Sorry, I recently have no capacity to work on this issue. I would appreciate if you can send the patch. 😢

tonytonyjan commented 1 year ago

FYI, I can't to reproduce the issue.

λ system_profiler SPSoftwareDataType | grep 'System Version'
      System Version: macOS 13.3.1 (a) (22E772610a)
λ gem install jaro_winkler
Fetching jaro_winkler-1.5.4.gem
Building native extensions. This could take a while...
Successfully installed jaro_winkler-1.5.4
1 gem installed
danillos commented 1 year ago

Hi, @tonytonyjan

Probably this issue is happening on Apple M1 (maybe M2) but not all the times I guess. It didn't happen to me using a MacBook M1 Pro. But a co-worker with a new MacBook M1 Pro, it happened.

I'm almost re-installing the macOS just to check if it happens in a brand-new installation.

pmoffe commented 1 year ago

I've had the same issue since macOS 13.3.1 (pre-(a) patch) and ruby 3.2.2 (via rbenv). When trying to install the solargraph gem, I receive the same error.

I'm using a Mac mini M1.

$ system_profiler SPSoftwareDataType | grep 'System Version'
      System Version: macOS 13.3.1 (a) (22E772610a)
$ gem install solargraph
Fetching rbs-2.8.4.gem
Building native extensions. This could take a while...
Successfully installed rbs-2.8.4
Building native extensions. This could take a while...
ERROR:  Error installing solargraph:
    ERROR: Failed to build gem native extension.

    current directory: /Users/username/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jaro_winkler-1.5.4/ext/jaro_winkler
/Users/username/.rbenv/versions/3.2.2/bin/ruby extconf.rb
creating Makefile

current directory: /Users/username/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jaro_winkler-1.5.4/ext/jaro_winkler
make DESTDIR\= sitearchdir\=./.gem.20230504-11702-ck8qnl sitelibdir\=./.gem.20230504-11702-ck8qnl clean

current directory: /Users/username/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jaro_winkler-1.5.4/ext/jaro_winkler
make DESTDIR\= sitearchdir\=./.gem.20230504-11702-ck8qnl sitelibdir\=./.gem.20230504-11702-ck8qnl
compiling adj_matrix.c
compiling codepoints.c
compiling jaro.c
compiling jaro_winkler.c
jaro_winkler.c:19:3: error: incompatible function pointer types passing 'VALUE (size_t, VALUE *, VALUE)' (aka 'unsigned long (unsigned long, unsigned long *, unsigned long)') to parameter of type 'VALUE (*)(int, union (unnamed union at /Users/username/.rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:271:1), VALUE)' (aka 'unsigned long (*)(int, union (unnamed at /Users/username/.rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:271:1), unsigned long)') [-Wincompatible-function-pointer-types]
  rb_define_singleton_method(rb_mJaroWinkler, "distance",
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/username/.rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:308:143: note: expanded from macro 'rb_define_singleton_method'
#define rb_define_singleton_method(obj, mid, func, arity)   RBIMPL_ANYARGS_DISPATCH_rb_define_singleton_method((arity), (func))((obj), (mid), (func), (arity))
                                                                                                                                              ^~~~~~
/Users/username/.rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:271:1: note: passing argument to parameter here
RBIMPL_ANYARGS_DECL(rb_define_singleton_method, VALUE, const char *)
^
/Users/username/.rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:254:72: note: expanded from macro 'RBIMPL_ANYARGS_DECL'
RBIMPL_ANYARGS_ATTRSET(sym) static void sym ## _m1(__VA_ARGS__, VALUE(*)(int, union { VALUE *x; const VALUE *y; } __attribute__((__transparent_union__)), VALUE), int); \
                                                                       ^
jaro_winkler.c:21:3: error: incompatible function pointer types passing 'VALUE (size_t, VALUE *, VALUE)' (aka 'unsigned long (unsigned long, unsigned long *, unsigned long)') to parameter of type 'VALUE (*)(int, union (unnamed union at /Users/username/.rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:271:1), VALUE)' (aka 'unsigned long (*)(int, union (unnamed at /Users/username/.rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:271:1), unsigned long)') [-Wincompatible-function-pointer-types]
  rb_define_singleton_method(rb_mJaroWinkler, "jaro_distance", rb_jaro_distance,
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/username/.rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:308:143: note: expanded from macro 'rb_define_singleton_method'
#define rb_define_singleton_method(obj, mid, func, arity)   RBIMPL_ANYARGS_DISPATCH_rb_define_singleton_method((arity), (func))((obj), (mid), (func), (arity))
                                                                                                                                              ^~~~~~
/Users/username/.rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:271:1: note: passing argument to parameter here
RBIMPL_ANYARGS_DECL(rb_define_singleton_method, VALUE, const char *)
^
/Users/username/.rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:254:72: note: expanded from macro 'RBIMPL_ANYARGS_DECL'
RBIMPL_ANYARGS_ATTRSET(sym) static void sym ## _m1(__VA_ARGS__, VALUE(*)(int, union { VALUE *x; const VALUE *y; } __attribute__((__transparent_union__)), VALUE), int); \
                                                                       ^
2 errors generated.
make: *** [jaro_winkler.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/username/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jaro_winkler-1.5.4 for inspection.
Results logged to /Users/username/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/extensions/arm64-darwin-22/3.2.0/jaro_winkler-1.5.4/gem_make.out
Frederick888 commented 1 year ago

Does #52 solve this issue?

I tested rake compare under macOS (Intel) with Ruby 3.2.2, 3.1.3, 2.7.8, and 2.7.7 and it looked alright. Not familiar with Ruby extension APIs so not sure if it's a proper solution.

tonytonyjan commented 1 year ago

hi @mrblrrd, I just merged ths PR #52, can you pull the latest master branch and see if it solves your issue? Thank you!

mrblrrd commented 1 year ago

@tonytonyjan yes it does, thanks!

Ruslans-MacBook-Pro:jaro_winkler ruslan$ rake compile
mkdir -p tmp/arm64-darwin22/jaro_winkler_ext/3.2.2
cd tmp/arm64-darwin22/jaro_winkler_ext/3.2.2
/Users/ruslan/.rbenv/versions/3.2.2/bin/ruby -I. -r.rake-compiler-siteconf.rb ../../../../ext/jaro_winkler/extconf.rb
creating Makefile
cd -
cd tmp/arm64-darwin22/jaro_winkler_ext/3.2.2
/usr/bin/make
compiling ../../../../ext/jaro_winkler/adj_matrix.c
compiling ../../../../ext/jaro_winkler/codepoints.c
compiling ../../../../ext/jaro_winkler/jaro.c
compiling ../../../../ext/jaro_winkler/jaro_winkler.c
linking shared-object jaro_winkler/jaro_winkler_ext.bundle
cd -
mkdir -p tmp/arm64-darwin22/stage/lib/jaro_winkler
/usr/bin/make install target_prefix=
/usr/bin/install -c -m 0755 jaro_winkler_ext.bundle /Users/ruslan/repos/jaro_winkler/lib/jaro_winkler
cp tmp/arm64-darwin22/jaro_winkler_ext/3.2.2/jaro_winkler_ext.bundle tmp/arm64-darwin22/stage/lib/jaro_winkler/jaro_winkler_ext.bundle
Ruslans-MacBook-Pro:jaro_winkler ruslan$ 
tonytonyjan commented 1 year ago

FYI, I just released v1.5.5 with the fix. 🎉

pmoffe commented 1 year ago

FYI, I just released v1.5.5 with the fix. 🎉

Confirmed - working as expected.

~ gem install jaro_winkler
Fetching jaro_winkler-1.5.5.gem
Building native extensions. This could take a while...
Successfully installed jaro_winkler-1.5.5
Parsing documentation for jaro_winkler-1.5.5
Installing ri documentation for jaro_winkler-1.5.5
Done installing documentation for jaro_winkler after 0 seconds