File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 10
10
# Otherwise, --disable-gems would degrade startup which is counter-intuitive.
11
11
Truffle ::Boot . delay do
12
12
if Truffle ::Boot . get_option 'rubygems'
13
+ module Truffle ::LazyRubyGems
14
+ end
15
+
13
16
module Kernel
14
17
# Take this alias name so RubyGems will reuse this copy
15
18
# and skip the method below once RubyGems is loaded.
@@ -20,10 +23,18 @@ module Kernel
20
23
gem_original_require ( path )
21
24
rescue LoadError
22
25
gem_original_require 'rubygems'
23
- require path
26
+
27
+ # Check that #require was redefined by RubyGems, otherwise we would end up in infinite recursion
28
+ new_require = ::Kernel . instance_method ( :require )
29
+ if new_require == Truffle ::LazyRubyGems ::LAZY_REQUIRE
30
+ raise 'RubyGems did not redefine #require as expected, make sure $LOAD_PATH and home are set correctly'
31
+ end
32
+ new_require . bind ( self ) . call ( path )
24
33
end
25
34
end
26
35
36
+ Truffle ::LazyRubyGems ::LAZY_REQUIRE = instance_method ( :require )
37
+
27
38
private def gem ( *args )
28
39
require 'rubygems'
29
40
gem ( *args )
You can’t perform that action at this time.
0 commit comments