|
1 |
| -if defined?(Gem) |
2 |
| - begin |
3 |
| - require 'rubygems' |
4 |
| - rescue LoadError |
5 |
| - # For JRUBY-5333, gracefully fail to load, since stdlib may not be available |
6 |
| - warn 'RubyGems not found; disabling gems' if $VERBOSE |
7 |
| - else |
| 1 | +# Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. This |
| 2 | +# code is released under a tri EPL/GPL/LGPL license. You can use it, |
| 3 | +# redistribute it and/or modify it under the terms of the: |
| 4 | +# |
| 5 | +# Eclipse Public License version 1.0 |
| 6 | +# GNU General Public License version 2 |
| 7 | +# GNU Lesser General Public License version 2.1 |
| 8 | + |
| 9 | +module Kernel |
| 10 | + # Take this alias name so RubyGems will reuse this copy |
| 11 | + # and skip the method below once RubyGems is loaded. |
| 12 | + alias :gem_original_require :require |
| 13 | + |
| 14 | + private def require(path) |
8 | 15 | begin
|
9 |
| - gem 'did_you_mean' |
10 |
| - require 'did_you_mean' |
11 |
| - Gem.clear_paths |
12 |
| - rescue Gem::LoadError, LoadError |
13 |
| - end if defined?(DidYouMean) |
| 16 | + gem_original_require(path) |
| 17 | + rescue LoadError |
| 18 | + require 'rubygems' |
| 19 | + require path |
| 20 | + end |
| 21 | + end |
| 22 | + |
| 23 | + private def gem(*args) |
| 24 | + require 'rubygems' |
| 25 | + gem(*args) |
14 | 26 | end
|
15 | 27 | end
|
| 28 | + |
| 29 | +class Object |
| 30 | + autoload :Gem, 'rubygems' |
| 31 | + |
| 32 | + # RbConfig is required by RubyGems, which makes it available in Ruby by default. |
| 33 | + # Autoload it since we do not load RubyGems eagerly. |
| 34 | + # autoload :RbConfig, 'rbconfig' |
| 35 | + # Defined by RbConfig |
| 36 | + # autoload :CROSS_COMPILING, 'rbconfig' |
| 37 | +end |
| 38 | + |
| 39 | +# if defined?(Gem) |
| 40 | +# begin |
| 41 | +# require 'rubygems' |
| 42 | +# rescue LoadError |
| 43 | +# # For JRUBY-5333, gracefully fail to load, since stdlib may not be available |
| 44 | +# warn 'RubyGems not found; disabling gems' if $VERBOSE |
| 45 | +# else |
| 46 | +# begin |
| 47 | +# gem 'did_you_mean' |
| 48 | +# require 'did_you_mean' |
| 49 | +# Gem.clear_paths |
| 50 | +# rescue Gem::LoadError, LoadError |
| 51 | +# end if defined?(DidYouMean) |
| 52 | +# end |
| 53 | +# end |
0 commit comments