Improve JRuby::Commands' handling of bindir
-------------------------------------------

                 Key: JRUBY-2862
                 URL: http://jira.codehaus.org/browse/JRUBY-2862
             Project: JRuby
          Issue Type: Improvement
          Components: Core Classes/Modules
    Affects Versions: JRuby 1.1.3
         Environment: uname -a : FreeBSD oogway.the 7.0-RELEASE-p3 FreeBSD 
7.0-RELEASE-p3 #0: Sun Jul 13 22:09:37 EDT 2008 [EMAIL 
PROTECTED]:/usr/obj/usr/src/sys/OOGWAY20080712a amd64 

java -version : java version "1.6.0_07" / Diablo Java(TM) SE Runtime 
Environment (build 1.6.0_07-b02) / Diablo Java HotSpot(TM) 64-Bit Server VM 
(build 10.0-b23, mixed mode) 

ant -version : Apache Ant version 1.7.0 compiled on December 13 2006
            Reporter: Geoff The
         Attachments: patch-commands.rb

JRuby::Commands assumes that bindir will contain at least a "jirb" command, and 
disables the built-in "gem" command even if it doesn not exist in bindir.

I ran into this while using the jruby port under FreeBSD 7.0/amd64 (though it 
isn't platform specific).

For background, the current FreeBSD port will:

1. install jruby and jrubyc to /usr/local/bin
2. install jruby's lib to /usr/local/share/jruby
3. patch /usr/local/bin/jruby to define JRUBY_HOME and JAVA_HOME

This means that under the port, JRUBY_HOME/bin does not exist, so running 
"jruby -S gem" will cause JRuby::Commands to invoke the locally def'd "gem" 
method.

However, with the current implementation of JRuby::Commands, if bindir aka 
JRUBY_HOME/bin exists, even if it is empty, the 'gem' and 'jirb' methods will 
not be defined, and running "jruby -S gem" will produce:

{noformat}
Exception in thread "main" 
file:/usr/local/share/jruby/lib/jruby.jar!/jruby/commands.rb:1: undefined 
method `jirb' for class `#<Class:01x686963d0>' (NameError)
        from file:/usr/local/share/jruby/lib/jruby.jar!/jruby/commands.rb:1
        from file:/usr/local/share/jruby/lib/jruby.jar!/jruby/commands.rb:1
        from file:/usr/local/share/jruby/lib/jruby.jar!/jruby/commands.rb:1
        from file:/usr/local/share/jruby/lib/jruby.jar!/jruby/commands.rb:1
        ...internal jruby stack elided...
{noformat}

Note the error refers to the "jirb" command -- this is because JRuby::Commands 
attempts to "alias_method :irb, :jirb" even if :jirb doesn't exist.

The attached patch will always define "gem" and "jirb" (which will get 
redefined if they exist in bindir), allowing them to always be accessible and 
avoiding the alias_method error.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to