[Rubygems-developers] Questions on 1.0.0 on JRuby

Stephen Bannasch stephen.bannasch at deanbrook.org
Mon Apr 7 13:58:42 EDT 2008

At 1:03 PM -0300 4/7/08, Luis Lavena wrote:
>On Mon, Apr 7, 2008 at 12:28 PM, Charles Oliver Nutter
><charles.nutter at sun.com> wrote:
>> Charles Oliver Nutter wrote:
>>  > 1. jgem?
>>  >
>>  > I saw this during the 1.0.0 install:
>>  >
>>  > install -c -m 0755 /tmp/gem /Users/headius/NetBeansProjects/jruby/bin/jgem
>>  >
>>  > Why jgem? We've been shipping with just 'gem'.
>>  It took me a couple months to notice this had been closed without being
>>  fixed:
>>  http://rubyforge.org/tracker/index.php?func=detail&aid=16879&group_id=126&atid=575
>>  I disgree that 'jgem' should be the default, since many people that run
>>  JRuby run only JRuby, tutorials state 'gem' as the command, and people
>>  are used to typing 'gem'. If people are using both JRuby and Ruby and
>>  want to avoid naming conflicts, they can add an alias easily enough or
>>  juggle PATH entries. But JRuby is "just another Ruby impl" and shouldn't
>>  have a different command name for installing gems.
>>  Can we please have the 'gem' name as default when installing on JRuby?
>I can point you to several posts of people with messed PATH and ended
>with problems installing gem, just a few weeks back, here on this

Changing the name to jgem will just delay the mess Daniel was getting into for a little while.

Daniels problem was that he was running the jruby gem when he thought he was running the mri gem. This is presumably because he had modified the windows equivalent of PATH so that the path to jruby.home/bin came ahead of the MRI one.

Changing the name to jgem fixes that confusion ... but as long as people want to run two or more versions of a  ruby vm moving the alternate.ruby.vm/bin path to the top of the PATH list is going to be fragile.

Almost nobody will type jgem when they intend to type gem but by putting alternate.ruby.vm/bin first on the PATH they could then easily type some other installed ruby command which would then run in the alternate.ruby.vm without noticing.

In general MRI Ruby either comes installed in a system or can be installed as a system package -- in general I think that's the Ruby that should run when someone types gem, rake, ri, etc.

When you want to run alternate.ruby.vm/bin/gem first make sure that alternate.ruby.vm/bin is on the PATH at the end and type this instead:

  $ alternate.ruby.vm -S gem
  $ alternate.ruby.vm -S rake
  $ alternate.ruby.vm -S ri

If that's too much typing make an alias

  jgem=jruby -S gem

If you want to only use alternate.ruby.vm and you want to treat it in effect as your system ruby for a while construct an install architecture so the whole thing can be switched easily.

So for example:


could be a symbolic link pointing to


And all the rest of the environment variables are setup accordingly when you switch ruby vms.

I haven't heard about anybody who is running two or more ruby vms and wants them to share the same local gem local cache.

If you have to separate the gem caches then you'll need to separate the ruby.vm/bin directories -- unless you apply the renaming commands to every gem installed (and rename the existing gems commands when rubygems is updated).

I like having multiple vms and being in a program directory and being able to type:

  ruby test_my_app.rb
  jruby -S test_my_app.rb

and know for sure what gems and libraries will be used.

>I got several mails to my inbox about Mongrel too, and some "new" ones
>for One-Click Installer...
>So the thing is: if JRuby uses RubyGems, and 'ruby' executable is
>labeled 'jruby', why not name rubygems 'jgem'?
>In any case, there should be a warning or something if another ruby
>implementation is in the PATH...

>I don't know how to fix this and makes everybody happy...

Maybe this method could help achieve a larger goal:

def find_all_gem_commands(gem_command='gem')
  gem_command_locations = ENV['PATH'].split(':').find_all {|path| File.exists?(path + File::SEPARATOR + gem_command)}.uniq
  gem_command_locations =  gem_command_locations.collect {|path| path + File::SEPARATOR + gem_command}
  gem_commands = {}
  gem_command_locations.each do |location|
    gem_commands[location]=File.open(location) {|f| f.gets.strip}[/\w*$/]

=> {"/usr/bin/gem"=>"ruby", "/Users/stephen/dev/jruby_trunk/jruby/bin/gem"=>"jruby"}

=> {"/Users/stephen/dev/jruby_trunk/jruby/bin/rake"=>"jruby", "/usr/bin/rake"=>"ruby"}

More information about the Rubygems-developers mailing list