Lack of default jruby.home in embedded usage causes NPE
-------------------------------------------------------

                 Key: JRUBY-3253
                 URL: http://jira.codehaus.org/browse/JRUBY-3253
             Project: JRuby
          Issue Type: Bug
          Components: Interpreter
    Affects Versions: JRuby 1.1.6
            Reporter: Peter K Chan


In embedded usage of JRuby 1.1.6, if the embedder does not provide a jruby.home 
value, the runtime will raise a NPE when shelling out to execute some shell 
commands.

The immediate offending code is at RbConfigLibrary.java:119. Specifically, the 
line:

setConfig(configHash, "prefix", normalizedHome);

where normalizedHome is derived from jruby.home and is null, thus causing the 
NPE.

A proper resolution of this issue will involve either providing a sensible 
default jruby.home value, or finding other parts of the runtime that depends on 
jruby.home, even when the runtime is embedded.

As a workaround, System.setProprety("jruby.home", 
System.getProperty("java.io.tmpdir")) seems to work to avoid the NPE.

A short discussion from the mailing list is quoted below.

{quote}
> From: [email protected] [mailto:[email protected]] On 
> Behalf Of Charles Oliver Nutter
> Sent: Wednesday, December 17, 2008 8:37 PM
> To: [email protected]
> Subject: Re: [jruby-user] Proper jruby.home setting for an embedded 
> app? (NPE in 1.1.6)
>
> Peter K Chan wrote:
>> What is the proper value for jruby.home in an embedded runtime?
>>
>> It seems that in 1.1.5, the value defaults at being HOME/.jruby. In 
>> 1.1.6, the value ends up being null and causing a NPE.
>>
>> I tried to provide a default value of NOT_AVAILABLE, which works 
>> around the NPE, but then I see a new directory called NOT_AVAILABLE 
>> created after the run.
>>
>> The proximal cause that needed the jruby.home value is shelling out; i.e.
>> `echo hi` caused NPE in my embedded 1.1.6 runtime, unless I provide a 
>> jruby.home value (which then gets created as a directory).
>>
>> What is the proper way to tell the runtime that there is no 
>> jruby.home value available and that it shouldn't try to create a jruby.home 
>> directory?
>
> That would be a regression; we wanted to boot the .jruby dir, since it 
> just caused problems, but I guess we didn't put a reasonable default 
> in its place. So...we need a bug for that.
>
> Meanwhile, you could probably set it to any existing dir, maybe a 
> dummy location? /tmp? Sorry for the mixup with this one, I guess it 
> wasn't caught during the RC. Toss your full description into a bug and 
> maybe come up with a patch if you have a chance.
{quote}

-- 
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