Skip to content

Commit

Permalink
[GR-18163] Set @gem_prelude_index variable on the default load paths
Browse files Browse the repository at this point in the history
PullRequest: truffleruby/3157
  • Loading branch information
bjfish committed Feb 3, 2022
2 parents 1c1d3df + c8725b5 commit 752a2f3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Compatibility:
* Add patch for `digest` so that TruffleRuby implementation is not overridden (@bjfish).
* Handle encoding conversion errors when reading directory entries (@aardvark179).
* Follow symlinks when processing `*/` directory glob patterns. (#2589, @aardvark179).
* Set `@gem_prelude_index` variable on the default load paths (#2586 , @bjfish)

Performance:

Expand Down
10 changes: 10 additions & 0 deletions spec/ruby/language/predefined_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,8 @@ def obj.foo2; yield; end
it "can be changed via <<" do
$: << "foo"
$:.should include("foo")
ensure
$:.delete("foo")
end

it "is read-only" do
Expand All @@ -850,6 +852,14 @@ def obj.foo2; yield; end
$-I = []
}.should raise_error(NameError)
end

it "default $LOAD_PATH entries until sitelibdir included have @gem_prelude_index set" do
$:.should.include?(RbConfig::CONFIG['sitelibdir'])
idx = $:.index(RbConfig::CONFIG['sitelibdir'])

$:[idx..-1].all? { |p| p.instance_variable_defined?(:@gem_prelude_index) }.should be_true
$:[0...idx].all? { |p| !p.instance_variable_defined?(:@gem_prelude_index) }.should be_true
end
end

describe "Global variable $\"" do
Expand Down
2 changes: 2 additions & 0 deletions src/main/ruby/truffleruby/core/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ def p(*a)
$LOAD_PATH.push "#{ruby_home}/lib/truffle"
$LOAD_PATH.push "#{ruby_home}/lib/mri"
$LOAD_PATH.push "#{ruby_home}/lib/json/lib"

$LOAD_PATH.each { |p| p.instance_variable_set(:@gem_prelude_index, p) }
end
end

Expand Down

0 comments on commit 752a2f3

Please sign in to comment.