Skip to content

Commit

Permalink
ext: load C extension files from non-native gems via "require"
Browse files Browse the repository at this point in the history
and not "require relative"

Fixes #21
  • Loading branch information
flavorjones committed Dec 21, 2021
1 parent ea44527 commit 99cb027
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/magic.rb
Expand Up @@ -4,7 +4,10 @@
::RUBY_VERSION =~ /(\d+\.\d+)/
require_relative "magic/#{Regexp.last_match(1)}/magic"
rescue LoadError
require_relative 'magic/magic'
# use "require" instead of "require_relative" because non-native gems will place C extension files
# in Gem::BasicSpecification#extension_dir after compilation (during normal installation), which
# is in $LOAD_PATH but not necessarily relative to this file (see #21 and nokogiri#2300)
require 'magic/magic'
end

require_relative 'magic/version'
Expand Down

0 comments on commit 99cb027

Please sign in to comment.