Skip to content

Commit

Permalink
Check versions without accessing Gem
Browse files Browse the repository at this point in the history
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 ffi#763 for the original code.
  • Loading branch information
headius committed Sep 22, 2020
1 parent 10ea06e commit b0f9d16
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/ffi.rb
Expand Up @@ -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'

Expand Down

0 comments on commit b0f9d16

Please sign in to comment.