Skip to content

Commit

Permalink
Merge pull request #27 from kwilczynski/21-require-library-in-ext
Browse files Browse the repository at this point in the history
ext: load C extension files from non-native gems via "require"
  • Loading branch information
stanhu committed Dec 22, 2021
2 parents 0026bd0 + 37d61ff commit 500a9d5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/magic.rb
Original file line number Diff line number Diff line change
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 500a9d5

Please sign in to comment.