Skip to content

Commit e3c2423

Browse files
Ruby: Fix native extension loading for new RubyGems (Ruby 4.1+) (#1281)
This pull request changes the native extension loading from `require_relative` to `require` to ensure compatibility with the latest RubyGems, which no longer installs native extensions into the gem's `lib/` directory by default. See ruby/rubygems#9240. Using `require` resolves the extension through `$LOAD_PATH`, which RubyGems populates with both the `lib/` and extension directories, so this works on both old and new versions of RubyGems. Resolves #1244 Co-Authored-By: Daniel Colson <composerinteralia@github.com>
1 parent ca67d2e commit e3c2423

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/herb.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@
3535
major, minor, _patch = RUBY_VERSION.split(".") #: [String, String, String]
3636

3737
if RUBY_PATCHLEVEL == -1
38-
require_relative "herb/herb"
38+
require "herb/herb"
3939
else
4040
begin
41-
require_relative "herb/#{major}.#{minor}/herb"
41+
require "herb/#{major}.#{minor}/herb"
4242
rescue LoadError
43-
require_relative "herb/herb"
43+
require "herb/herb"
4444
end
4545
end
4646
rescue LoadError => e

0 commit comments

Comments
 (0)