tags:

views:

287

answers:

3

Has anyone seen this: ?? No jgem command works at all?? Though jruby -S gem list does work. I'm using jruby 1.3.1 and Sun Java6 jre

root@test:/usr/local: jgem --version  
1.3.3  

root@test:/usr/local: jgem update --system  
JRuby limited openssl loaded. gem install jruby-openssl for full support.
http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
Updating RubyGems
Updating rubygems-update
Successfully installed rubygems-update-1.3.6
/usr/local/jruby/lib/ruby/site_ruby/1.8/rubygems/commands/update_command.rb:103:Warning: Gem::SourceIndex#search support for String patterns is deprecated
Updating RubyGems to 1.3.6
Installing RubyGems 1.3.6
RubyGems 1.3.6 installed  

root@test:/usr/local: jgem list  
/usr/local/jruby/bin/jgem: line 8: require: command not found
/usr/local/jruby/bin/jgem: line 9: require: command not found
/usr/local/jruby/bin/jgem: line 10: require: command not found
/usr/local/jruby/bin/jgem: line 12: required_version: command not found
/usr/local/jruby/bin/jgem: line 14: unless: command not found
/usr/local/jruby/bin/jgem: line 15: abort: command not found
/usr/local/jruby/bin/jgem: line 16: end: command not found
/usr/local/jruby/bin/jgem: line 18: args: command not found
/usr/local/jruby/bin/jgem: line 20: begin: command not found
/usr/local/jruby/bin/jgem: line 21: Gem::GemRunner.new.run: command not found
/usr/local/jruby/bin/jgem: line 22: rescue: command not found
/usr/local/jruby/bin/jgem: line 23: exit: e.exit_code: numeric argument required
A: 

Given that line 8 in the jgem script is the first line of ruby (the rest are comments/blanks) I'd say something broke (j)ruby in your shell.

Try starting a new shell session and see if it's just transient.

Try these:

jruby -v

jirb

etc...

Rob
brad@test:~$ jruby -v jruby 1.3.1 (ruby 1.8.6p287) (2009-06-15 2fd6c3d) (Java HotSpot(TM) Client VM 1.6.0_07) [i386-java]brad@test:~$ jirb irb(main):001:0> exit Both work. Also, jruby works for sure because the jruby -S syntax works fine, just not jgem
brad
ugh, ok i can't format that apparently, but it's showing that both commands worked. This is on linux btw. I'm hesitant to do an update on OSX as I enjoy using jgem and i have 1.3.5 anyway which is all i really need
brad
checking those files, I notice that the top line setting the interpreter is different. 1.3.6 has #!/usr/local/jruby/bin/jruby and 1.3.5 has #!/usr/bin/env jruby I wonder why the difference? obviously 1.3.6's is not loading ruby properly. I don't know enough about shell scripts to really say what's going on. Replacing 1.3.6's interpreter line with 1.3.5's #!/usr/bin/env jruby works btw.
brad
Try JRUby 1.4.0 (which I have). It doesn't have to be permanent if you don't want. You might get away with copying the jgem script from 1.4.0 to whatever version you want to run.
Rob
ya i actually use jruby 1.4 locally also, in a transitional upgrade and it works. It's just with 1.3.1 on our staging/production servers that i noticed this
brad
+1  A: 

Note that this only seemed to happen on Linux (not OSX) And I fixed it by replacing the line at the top of the jgem script from:

#!/mnt/java/jruby-1.4.0/bin/jruby

to

#!/usr/bin/env jruby
brad
A: 

There is a shell limitation: inability to use shell scripts in shebang lines, and since JRuby's launcher is (was) shell-based, that breaks things. The good news is that JRuby now has native launcher (for windows, linux, macos), and using it instead of shell launcher would allow to put it in shebang lines with no problem.

VVSiz