tonytonyjan / jaro_winkler

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

support windows #18

Open tonytonyjan opened 6 years ago

bbatsov commented 6 years ago

I guess this just re-emerged in the context of RuboCop - see https://github.com/rubocop-hq/rubocop/issues/5989

Perhaps on Windows you can just fallback automatically to the pure Ruby version?

tonytonyjan commented 6 years ago

The issue seems similar to this: https://stackoverflow.com/questions/19176136/make-is-not-recognized-as-internal-or-external-command

In theory, it should have worked on Windows since the extension is implemented with CRuby's interface, but I never had tested jaro_winkler on windows before.

I'll confirm this issue on windows 10 later.

tonytonyjan commented 6 years ago

Oops, I suddenly realized I misread rubocop-hq/rubocop#5989, it's JRuby on windows platform.

rtdevlin commented 6 years ago

I'm still seeing this issue on 64 bit Ruby2.3.1 on Windows. Popped up with recent Rubocop update

tonytonyjan commented 6 years ago

@rtdevlin Would you paste the full error message here, thank you!

rtdevlin commented 6 years ago

current directory: C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/jaro_winkler-1.5.1/ext/jaro_winkler

C:/Ruby23-x64/bin/ruby.exe -r ./siteconf20180703-277200-1fzi9md.rb extconf.rb

creating Makefile

current directory: C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/jaro_winkler-1.5.1/ext/jaro_winkler

make "DESTDIR=" clean

current directory: C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/jaro_winkler-1.5.1/ext/jaro_winkler

make "DESTDIR="

generating jaro_winkler_ext-x64-mingw32.def

make: Error -- Don't know how to make /C/Ruby23-x64/include/ruby-2.3.0/ruby.h

make failed, exit code 255

tonytonyjan commented 6 years ago

@rtdevlin I am not able to reproduce your issue:

C:\Users\User>ver

Microsoft Windows [Version 10.0.17134.48]

C:\Users\User>ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x64-mingw32]

C:\Users\User>gem install jaro_winkler
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
Successfully installed jaro_winkler-1.5.1
Parsing documentation for jaro_winkler-1.5.1
Installing ri documentation for jaro_winkler-1.5.1
Done installing documentation for jaro_winkler after 0 seconds
1 gem installed

C:\Users\User>ruby -rjaro_winkler -e 'puts JaroWinkler.distance "tony", "tomy"'
0.8666666666666667

I guess It might have something to do with your building environment. Are you able to install other C extensions? For example: gem install thin

rtdevlin commented 6 years ago

I wasn't able to install thin, but I know I've installed gems that required the Devkit and it worked. The only difference I see right now is Windows versions. I'm going to try to install on my home machine (the issue I'm having is at work, else I wouldn't be using Windows)

rtdevlin commented 6 years ago

Was able to install on Windows 10. Thanks for looking into the issue, I'll continue trying to figure out what's wrong with my machine

lsegal commented 5 years ago

Still running into issues on this. Windows 10 x64:

λ gem install jaro_winkler
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
ERROR:  Error installing jaro_winkler:
        ERROR: Failed to build gem native extension.

    current directory: C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/jaro_winkler-1.5.2/ext/jaro_winkler
C:/tools/ruby25/bin/ruby.exe -I C:/tools/ruby25/lib/ruby/site_ruby/2.5.0 -r ./siteconf20190327-192408-kgbemo.rb extconf.rb
creating Makefile

current directory: C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/jaro_winkler-1.5.2/ext/jaro_winkler
make "DESTDIR=" clean

current directory: C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/jaro_winkler-1.5.2/ext/jaro_winkler
make "DESTDIR="
generating jaro_winkler_ext-x64-mingw32.def
make: *** No rule to make target '/C/tools/ruby25/include/ruby-2.5.0/ruby.h', needed by 'adj_matrix.o'.  Stop.

make failed, exit code 2

Gem files will remain installed in C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/jaro_winkler-1.5.2 for inspection.
Results logged to C:/tools/ruby25/lib/ruby/gems/2.5.0/extensions/x64-mingw32/2.5.0/jaro_winkler-1.5.2/gem_make.out
kenliu commented 5 years ago

I was able to fix this by uninstalling ruby (installed via Chocolatey) and manually installing RubyInstaller+DevKit https://rubyinstaller.org/downloads/

Dainii commented 4 years ago

If it can help someone, I had the same issue and the problem was the path of my ruby installation. It was installed in "C:\Program Files\ruby" and Make does not seems to like the space in the path of the executables.

So I moved the folder elsewhere (like "C:\DATA") and it works now.

okmanideep commented 1 year ago

For folks who use scoop on Windows

$ scoop install ruby
$ scoop install msys2
$ ridk install
# PRESS ENTER (installs MSYS2 + MINGW Development Kit)  

This should make gem install jaro_winkler work just fine

Slach commented 1 year ago

@okmanideep thanks for sharing. it works