Skip to content

Commit e095283

Browse files
committed
[Truffle] Support --disable-gems.
1 parent 9f5aab4 commit e095283

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

core/src/main/java/org/jruby/util/cli/ArgumentProcessor.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,6 @@ private void processArgument() {
406406
config.setCompileMode(RubyInstanceConfig.CompileMode.TRUFFLE);
407407
// Make the static option consistent with the compile mode.
408408
Options.COMPILE_MODE.force("TRUFFLE");
409-
config.setDisableGems(true);
410409
} else if (extendedOption.endsWith("...")) {
411410
Options.listPrefix(extendedOption.substring(0, extendedOption.length() - "...".length()));
412411
config.setShouldRunInterpreter(false);

truffle/src/main/java/org/jruby/truffle/language/TruffleBootNodes.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,16 @@ public DynamicObject originalLoadPath() {
158158

159159
}
160160

161+
@CoreMethod(names = "rubygems_enabled?", onSingleton = true)
162+
public abstract static class RubygemsEnabledNode extends CoreMethodNode {
163+
164+
@Specialization
165+
public boolean isRubygemsEnabled() {
166+
return !getContext().getInstanceConfig().isDisableGems();
167+
}
168+
169+
}
170+
161171
@CoreMethod(names = "source_of_caller", isModuleFunction = true)
162172
public abstract static class SourceOfCallerNode extends CoreMethodArrayArgumentsNode {
163173

truffle/src/main/ruby/post-boot/gems.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
rescue LoadError
1212
end
1313

14-
begin
15-
require 'rubygems'
16-
rescue LoadError
17-
warn('Could not load RubyGems during runtime bootstrap. Please set JRUBY_HOME to an appropriate location.')
18-
end
14+
if Truffle::Boot.rubygems_enabled?
15+
begin
16+
require 'rubygems'
17+
rescue LoadError
18+
warn('Could not load RubyGems during runtime bootstrap. Please set JRUBY_HOME to an appropriate location.')
19+
end
20+
end

truffle/src/main/ruby/post-boot/shims.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
# GNU General Public License version 2
77
# GNU Lesser General Public License version 2.1
88

9-
module Gem
10-
# Update the default_dir to match JRuby's.
11-
def self.default_dir
12-
File.expand_path(File.join(ConfigMap[:libdir], '..', '..', 'ruby', 'gems', 'shared'))
9+
if Truffle::Boot.rubygems_enabled?
10+
module Gem
11+
# Update the default_dir to match JRuby's.
12+
def self.default_dir
13+
File.expand_path(File.join(ConfigMap[:libdir], '..', '..', 'ruby', 'gems', 'shared'))
14+
end
1315
end
1416
end

0 commit comments

Comments
 (0)