mirror of
https://github.com/ruby/ruby.git
synced 2026-01-26 12:14:51 +00:00
[ruby/rubygems] Fix native extension loading in newgem template for RHEL-based systems
Add fallback to `require` when `require_relative` fails to load native extensions. This addresses an issue on RHEL-based Linux distributions where Ruby scripts and built native extension shared libraries are installed in separate directories. https://github.com/ruby/rubygems/commit/68599bd107
This commit is contained in:
parent
a82aa08fe0
commit
1de15815a8
@ -2,7 +2,7 @@
|
||||
|
||||
require_relative "<%= File.basename(config[:namespaced_path]) %>/version"
|
||||
<%- if config[:ext] -%>
|
||||
require_relative "<%= File.basename(config[:namespaced_path]) %>/<%= config[:underscored_name] %>"
|
||||
require "<%= File.basename(config[:namespaced_path]) %>/<%= config[:underscored_name] %>"
|
||||
<%- end -%>
|
||||
|
||||
<%- config[:constant_array].each_with_index do |c, i| -%>
|
||||
|
||||
@ -1681,6 +1681,13 @@ RSpec.describe "bundle gem" do
|
||||
expect(bundled_app("#{gem_name}/ext/#{gem_name}/#{gem_name}.c")).to exist
|
||||
end
|
||||
|
||||
it "generates native extension loading code" do
|
||||
expect(bundled_app("#{gem_name}/lib/#{gem_name}.rb").read).to include(<<~RUBY)
|
||||
require_relative "test_gem/version"
|
||||
require "#{gem_name}/#{gem_name}"
|
||||
RUBY
|
||||
end
|
||||
|
||||
it "includes rake-compiler, but no Rust related changes" do
|
||||
expect(bundled_app("#{gem_name}/Gemfile").read).to include('gem "rake-compiler"')
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user