From b0f9d160b9d9f2e41cdd289caad8ea806b45cb8b Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Tue, 22 Sep 2020 01:02:40 -0500 Subject: [PATCH] Check versions without accessing Gem When running with --disable-gems, we still need to be able to load FFI from stdlib. Accessing the Gem namespace here requires that gems not be disabled. This patch splits and compares the integer elements of version directly rather than using Gem::Version to do that comparison. See #763 for the original code. --- lib/ffi.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ffi.rb b/lib/ffi.rb index e6c75a7b9..d9e741582 100644 --- a/lib/ffi.rb +++ b/lib/ffi.rb @@ -8,11 +8,11 @@ require 'ffi/ffi' -elsif RUBY_ENGINE == 'jruby' && Gem::Version.new(RUBY_ENGINE_VERSION) >= Gem::Version.new("9.3.pre") +elsif RUBY_ENGINE == 'jruby' && (RUBY_ENGINE_VERSION.split('.').map(&:to_i) <=> [9, 3]) >= 0 JRuby::Util.load_ext("org.jruby.ext.ffi.FFIService") require 'ffi/ffi' -elsif RUBY_ENGINE == 'truffleruby' && Gem::Version.new(RUBY_ENGINE_VERSION) >= Gem::Version.new("20.1.0-dev-a") +elsif RUBY_ENGINE == 'truffleruby' && (RUBY_ENGINE_VERSION.split('.').map(&:to_i) <=> [20, 1, 0]) >= 0 require 'truffleruby/ffi_backend' require 'ffi/ffi'