Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with launching sub-jruby #4030

Open
ketan opened this issue Jul 26, 2016 · 4 comments
Open

Issues with launching sub-jruby #4030

ketan opened this issue Jul 26, 2016 · 4 comments

Comments

@ketan
Copy link
Member

ketan commented Jul 26, 2016

Environment

Provide at least:

  • JRuby version (jruby -v) and command line (flags, JRUBY_OPTS, etc)

jruby 1.7.25 (1.9.3p551) 2016-04-13 867cb81 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_79-b15 +jit [darwin-x86_64]

also reproducible with

jruby 9.1.2.0 (2.3.0) 2016-05-26 7357c8f Java HotSpot(TM) 64-Bit Server VM 24.79-b02 on 1.7.0_79-b15 +jit [darwin-x86_64]

  • Operating system and platform (e.g. uname -a)

Darwin ketanpkr.local 15.5.0 Darwin Kernel Version 15.5.0: Tue Apr 19 18:36:36 PDT 2016; root:xnu-3248.50.21~8/RELEASE_X86_64 x86_64 i386 MacBookPro11,4 Darwin

Expected Behavior

With the attached code, I'm able to run fine with MRI. Tested on 1.9.3p551, 2.0.0p648, 2.1.5p273 2.2.4p230

The output I see is —

$ ruby foo.rb
inside foo.rb
/Users/ketanpadegaonkar/.rbenv/versions/1.9.3-p551/bin/ruby bar.rb foo=bar
inside bar.rb ["foo=bar"]

Actual Behavior

The actual behavior with both jruby 1.7.25 and 9.1.2.0 is —

$ java -cp jruby-complete.jar org.jruby.Main foo.rb
inside foo.rb
java -cp :/Users/ketanpadegaonkar/.gradle/caches/modules-2/files-2.1/org.jruby/jruby-complete/1.7.25/8eb234259ec88edc05eedab05655f458a84bfcab/jruby-complete-1.7.25.jar org.jruby.Main bar.rb foo=bar
RuntimeError: Command failed with status (127): [java -cp :/Users/ketanpadegaonkar/.gradle/...]
  create_shell_runner at /Users/ketanpadegaonkar/.gradle/caches/modules-2/files-2.1/org.jruby/jruby-complete/1.7.25/8eb234259ec88edc05eedab05655f458a84bfcab/jruby-complete-1.7.25.jar!/META-INF/jruby.home/lib/ruby/shared/rake/file_utils.rb:55
                 call at org/jruby/RubyProc.java:281
                   sh at /Users/ketanpadegaonkar/.gradle/caches/modules-2/files-2.1/org.jruby/jruby-complete/1.7.25/8eb234259ec88edc05eedab05655f458a84bfcab/jruby-complete-1.7.25
@ketan
Copy link
Member Author

ketan commented Jul 26, 2016

The files that I'm running —

# foo.rb
require 'rake'
require 'rake/file_utils'
include FileUtils

puts "inside foo.rb"

ruby 'bar.rb', 'foo=bar'
# bar.rb
puts "inside bar.rb #{ARGV.inspect}"

@ketan
Copy link
Member Author

ketan commented Jul 27, 2016

The problem seems to be how ENV['RUBY'] is setup — it is set to java -cp jruby-complete.jar org.jruby.Main

Rake, in the meanwhile uses ENV['RUBY'] to determine the executable, and adds the remaining arguments to ENV['RUBY'] as part of the ruby call, so eventually the arguments to spawn end up being —

["java -cp jruby-complete.jar org.jruby.Main", "bar.rb" "foo=bar"]

This is clearly a problem because the arguments really need to be ["java", "-cp", "jruby-complete.jar", "org.jruby.Main", "bar.rb", "foo=bar"]

I'm not sure what the fix should be.

Is there a workaround that someone know that'll allow me to use the jruby-complete jar to create a subshell?

@mkristian
Copy link
Member

I thought there were one or two tests with jruby-complete.jar and rake.

I am bit confused about your example and the gradle classpath popping up from somewhere.

anyways IMO we should fix this, i.e. let spawn detect it is jruby launched from a classpath and split things.

@ketan
Copy link
Member Author

ketan commented Jul 27, 2016

If it helps avoid confusion — the gradle from the stacktrace is because I'm running jruby from the gradle cache, so the path shows up in the stacktrace.

This is how it looks like when running with jruby-complete from my downloads folder —

$ java -cp ~/Downloads/jruby-complete-9.1.2.0.jar org.jruby.Main foo.rb
inside foo.rb
java -cp :/Users/ketanpadegaonkar/Downloads/jruby-complete-9.1.2.0.jar org.jruby.Main bar.rb foo=bar
RuntimeError: Command failed with status (127): [java -cp :/Users/ketanpadegaonkar/Download...]
  block in create_shell_runner at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rake/file_utils.rb:67
                            sh at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rake/file_utils.rb:57
                            sh at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rake/file_utils_ext.rb:34
                          ruby at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rake/file_utils.rb:94
                          ruby at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rake/file_utils_ext.rb:34
                         <top> at foo.rb:7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants