Skip to content

Instantly share code, notes, and snippets.

@bjfish
Created February 18, 2016 19:38
Show Gist options
  • Save bjfish/840c11b171450642bdab to your computer and use it in GitHub Desktop.
Save bjfish/840c11b171450642bdab to your computer and use it in GitHub Desktop.
Enable ruby gems kernel methods
diff --git a/lib/ruby/truffle/mri/io/console.rb b/lib/ruby/truffle/mri/io/console.rb
new file mode 100644
index 0000000..b640b33
--- /dev/null
+++ b/lib/ruby/truffle/mri/io/console.rb
@@ -0,0 +1 @@
+# TODO BJF 18-Feb-2016 Replace shim thor <- bundler,
\ No newline at end of file
diff --git a/lib/ruby/truffle/mri/rubygems.rb b/lib/ruby/truffle/mri/rubygems.rb
index ad34fa7..c676a65 100644
--- a/lib/ruby/truffle/mri/rubygems.rb
+++ b/lib/ruby/truffle/mri/rubygems.rb
@@ -1239,8 +1239,8 @@ end
Gem::Specification.load_defaults
# JRuby+Truffle doesn't need these hacks.
-#require 'rubygems/core_ext/kernel_gem'
-#require 'rubygems/core_ext/kernel_require'
+require 'rubygems/core_ext/kernel_gem'
+require 'rubygems/core_ext/kernel_require'
Gem.use_gemdeps
diff --git a/truffle/src/main/java/org/jruby/truffle/core/kernel/KernelNodes.java b/truffle/src/main/java/org/jruby/truffle/core/kernel/KernelNodes.java
index ff5b1d2..d734151 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/kernel/KernelNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/kernel/KernelNodes.java
@@ -1570,7 +1570,8 @@ public abstract class KernelNodes {
final String feature = featureString.toString();
// Pysch loads either the jar or the so - we need to intercept
- if (feature.equals("psych.so") && callerIs("psych.rb")) {
+ if (feature.equals("psych.so") ) {
+// && callerIs("psych.rb")) { // TODO BJF 17-Feb-2016 new caller is rubygems require, is fix needed? how?
try {
getContext().getFeatureLoader().require("truffle/psych.rb", this);
} catch (IOException e) {
diff --git a/truffle/src/main/ruby/core/shims.rb b/truffle/src/main/ruby/core/shims.rb
index 65df444..4c4114a 100644
--- a/truffle/src/main/ruby/core/shims.rb
+++ b/truffle/src/main/ruby/core/shims.rb
@@ -188,13 +188,6 @@ class Exception
end
-# Hack to let code run that try to invoke RubyGems directly. We don't yet support RubyGems, but in most cases where
-# this call would be made, we've already set up the $LOAD_PATH so the call would no-op anyway.
-module Kernel
- def gem(*args)
- end
-end
-
# Find out why Rubinius doesn't implement this
class Rubinius::ARGFClass
@chrisseaton
Copy link

If this works for all our tests, and the jruby+truffle runner (which we don't have tests for but should), we can just merge this now. If it doesn't yet, and you can put this behind a feature switch, then we can still merge it.

@pitr-ch
Copy link

pitr-ch commented Apr 7, 2016

line 34: should not be needed any more, it now looks up further up the backtrace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment