Skip to content

Commit

Permalink
Check JRuby version without accessing Gem
Browse files Browse the repository at this point in the history
When running with --disable-gems, JRuby still needs to be able to
load FFI from stdlib. Accessing the Gem namespace here requires
that gems not be disabled.

This patch uses a simple split and integer comparison to compare
the first two digits of the JRuby version with 9.3.

See ffi#763 for the original code.
  • Loading branch information
headius committed Sep 22, 2020
1 parent 10ea06e commit 6f33774
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ffi.rb
Expand Up @@ -8,7 +8,7 @@

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('.').yield_self {|maj, min| maj.to_i >= 9 && min.to_i >= 3}
JRuby::Util.load_ext("org.jruby.ext.ffi.FFIService")
require 'ffi/ffi'

Expand Down

0 comments on commit 6f33774

Please sign in to comment.