Skip to content

Commit 752a2f3

Browse files
committed
[GR-18163] Set @gem_prelude_index variable on the default load paths
PullRequest: truffleruby/3157
2 parents 1c1d3df + c8725b5 commit 752a2f3

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Compatibility:
2525
* Add patch for `digest` so that TruffleRuby implementation is not overridden (@bjfish).
2626
* Handle encoding conversion errors when reading directory entries (@aardvark179).
2727
* Follow symlinks when processing `*/` directory glob patterns. (#2589, @aardvark179).
28+
* Set `@gem_prelude_index` variable on the default load paths (#2586 , @bjfish)
2829

2930
Performance:
3031

spec/ruby/language/predefined_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,8 @@ def obj.foo2; yield; end
835835
it "can be changed via <<" do
836836
$: << "foo"
837837
$:.should include("foo")
838+
ensure
839+
$:.delete("foo")
838840
end
839841

840842
it "is read-only" do
@@ -850,6 +852,14 @@ def obj.foo2; yield; end
850852
$-I = []
851853
}.should raise_error(NameError)
852854
end
855+
856+
it "default $LOAD_PATH entries until sitelibdir included have @gem_prelude_index set" do
857+
$:.should.include?(RbConfig::CONFIG['sitelibdir'])
858+
idx = $:.index(RbConfig::CONFIG['sitelibdir'])
859+
860+
$:[idx..-1].all? { |p| p.instance_variable_defined?(:@gem_prelude_index) }.should be_true
861+
$:[0...idx].all? { |p| !p.instance_variable_defined?(:@gem_prelude_index) }.should be_true
862+
end
853863
end
854864

855865
describe "Global variable $\"" do

src/main/ruby/truffleruby/core/post.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ def p(*a)
102102
$LOAD_PATH.push "#{ruby_home}/lib/truffle"
103103
$LOAD_PATH.push "#{ruby_home}/lib/mri"
104104
$LOAD_PATH.push "#{ruby_home}/lib/json/lib"
105+
106+
$LOAD_PATH.each { |p| p.instance_variable_set(:@gem_prelude_index, p) }
105107
end
106108
end
107109

0 commit comments

Comments
 (0)