Search code examples
javarubywindowsjruby

jruby-complete not running rake or other downloaded gems


In following the following URL for a guide:

http://spin.atomicobject.com/2010/02/01/running-a-ruby-application-with-jruby-complete/

I downloaded jruby-complete and was able to run a basic simple command or two. However, I wanted to run Rake. When I issued java -jar jruby-complete.jar -S rake -T, I was greeted with these errors on my Windows machine.

λ run_jruby.bat -S rake -T
io/console not supported; tty will not be manipulated
LoadError: no such file to load -- file:C:/Users/user01/Desktop/jruby_ant_tasks/jruby-complete-1.7.21.jar!/META-INF/jruby.home/lib/ruby/gems/shared/specifications/gems/rake-10.1.0/bin/rake
    load at org/jruby/RubyKernel.java:1059
  (root) at /C:/Users/user01/Desktop/jruby_ant_tasks/jruby-complete-1.7.21.jar!/META-INF/jruby.home/bin/rake:23

So then following this URL for more guidance:

http://spin.atomicobject.com/2013/04/24/bundler-jruby-complete/

I created a vendor\gem_home directory. Then installed bundler and rake using the following command:

λ run_jruby.bat -S gem install -i vendor\gem_home\ --no-rdoc --no-ri bundler rake
io/console not supported; tty will not be manipulated
Fetching: bundler-1.10.5.gem (100%)
Successfully installed bundler-1.10.5
Fetching: rake-10.4.2.gem (100%)
Successfully installed rake-10.4.2
2 gems installed

However, Bundler is not listed when I do a gem list

λ run_jruby.bat -S gem list --local
io/console not supported; tty will not be manipulated

*** LOCAL GEMS ***

jar-dependencies (0.1.15)
jruby-openssl (0.9.7 java)
json (1.8.0 java)
rake (10.1.0)
rdoc (4.1.2)

So then I ran the rake command again, and got the same error as above. When I run the bundle command, I get the following error:

λ run_jruby.bat -S bundle gem new_gem
ArgumentProcessor.java:565:in `resolveScript': java.lang.NullPointerException
        from ArgumentProcessor.java:523:in `runBinScript'
        from ArgumentProcessor.java:277:in `processArgument'
        from ArgumentProcessor.java:100:in `processArguments'
        from ArgumentProcessor.java:95:in `processArguments'
        from RubyInstanceConfig.java:196:in `processArguments'
        from Main.java:216:in `run'
        from Main.java:197:in `main'

Here is some more information about my system. My Java version is:

λ java -version
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

My JRuby version is:

λ run_jruby.bat -v
jruby 1.7.21 (1.9.3p551) 2015-07-07 a741a82 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_71-b14 +jit [Windows 7-amd64]

My run_jruby.bat file contains:

λ cat run_jruby.bat
@echo off

SET JAVA_COMMAND="java"
SET JAVA_OPTIONS="-jar"
SET JRUBY_BIN="jruby-complete-1.7.21.jar"
SET GEM_HOME="vendor\gem_home"
SET GEM_PATH="vendor\gem_home"

%JAVA_COMMAND% %JAVA_OPTIONS% %JRUBY_BIN% %*

I'm not sure what else I need to do as the Wiki didn't cover this part too much.

--2015-07-13 EDIT--
Just tried this same setup in RHEL 5.8 with IBM Java 1.6, and the Rake command works just fine, so it seems to be a Windows specific issue.


Solution

  • This seemed to be a bug with JRuby at the time of 1.7.21 build.

    https://github.com/jruby/jruby/issues/3133

    The JRuby binary was not checking for uninitialized environment PATH variables. The issue was fixed in 1.7.22 of JRuby.