Closed lwille closed 5 years ago
For your case, you can install the gem with --platform
flag, and require 'jaro_winkler/jaro_winkler_pure'
, for example:
$ gem install --platform java jaro_winkler
Successfully installed jaro_winkler-1.5.1-universal-java-10
1 gem installed
$ ruby -r jaro_winkler/jaro_winkler_pure -e 'puts JaroWinkler.distance "lwille", "lwi11e"'
0.8444444444444443
It works in docker image ruby:2.5.0-alpine3.7
, which has no built-in building environment:
$ docker run --rm ruby:2.5.0-alpine3.7 sh -c '\
gem install --platform java jaro_winkler > /dev/null && \
ruby -r jaro_winkler/jaro_winkler_pure -e \
"puts JaroWinkler.distance %q{lwille}, %{lwi11e}"'
0.8444444444444443
That's a great solution if you control how it's required.
I'm using it as a dependency of rubocop
.
I managed to work around it, so I'm not super keen on getting this patch merged.
I was looking for a way to select the pure ruby version, as there may be circumstances where we can't afford to compile the native extension (missing libraries and headers) and don't need the performance of a native extension.