JRuby

Reduce reliance on jruby.* system properties

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: JRuby 0.9.2
  • Fix Version/s: JRuby 0.9.8
  • Component/s: Core Classes/Modules
  • Labels:
    None
  • Number of attachments :
    0

Description

  • Add #getJRubyHome to IRuby, use instead of System.getProperty("jruby.home") everywhere.
  • Some rework to RbConfigLibrary to provide sensible defaults for some of the values
  • #getJRubyHome implementation uses System.getProperty("jruby.home") if provided, else falls back to ~/.jruby (this is to support JRUBY-419)

With these changes, org.jruby.Main can function without the jruby launcher script.

Issue Links

Activity

Hide
Charles Oliver Nutter added a comment -

Exactly the right things to fix.

  • getJRubyHome is great; should also probably provide a way to initialize it. I'm thinking we need to start moving woard a getRubyInstance method that accepts a "RubySetup" struct with a number of configurable values like in/out/err, whether objectspace is on or off, jruby home/etc locations, and so on. There's too much to pass into a factory method.
  • sensible defaults: FINALLY. I've had to force my own whenever I run a nontrivial app ouside jruby.sh
  • defaults for jruby home: what is the pwd for a Java app run from a shell script? Can we get the dir of the script somehow and set jruby.home to <that location>/..?
Show
Charles Oliver Nutter added a comment - Exactly the right things to fix.
  • getJRubyHome is great; should also probably provide a way to initialize it. I'm thinking we need to start moving woard a getRubyInstance method that accepts a "RubySetup" struct with a number of configurable values like in/out/err, whether objectspace is on or off, jruby home/etc locations, and so on. There's too much to pass into a factory method.
  • sensible defaults: FINALLY. I've had to force my own whenever I run a nontrivial app ouside jruby.sh
  • defaults for jruby home: what is the pwd for a Java app run from a shell script? Can we get the dir of the script somehow and set jruby.home to <that location>/..?
Hide
Nick Sieger added a comment -

Re: defaults for jruby.home, I see a couple different use cases here:

  1. People will either extract or install from a full distro, add $JRUBY_HOME/bin to their path and just use the jruby launcher script. In this case, jruby.home will always be determined by the script and passed on the command-line, so the default won't matter
  2. People will run with just the complete jar, maybe using some sort of --command= arg as you propose. In this case, unless jruby.home is specified, there should be someplace consistent that doesn't get in the way. If we default it to "user.dir" or some relative path to it, consistent invocation will require always running from that directory. I think this could get confusing.
  3. Embedded usages that still want to use rubygems. In this case, the embedding code should either set "jruby.home" (or possibly use IRuby#setJRubyHome, yet to be created, or some RubySetup struct like you propose), or it could just fall back to the default directory. Examples of ways I plan to use this soon are to create a maven jruby-rake-plugin to allow extending maven builds with bits of rake script. The embedded interpreter will need to download and cache a rake gem install, preferably without user intervention, and it would be nice to be able to re-use that gem install without cluttering PWD or having to re-install it every time.

Since I was aiming for something portable and not disruptive (e.g, requiring root/admin access to install in some shared directory), I thought putting it in a dot-named directory under ~/ best met these needs. If you think it's too magic, feel free to weigh in.

Show
Nick Sieger added a comment - Re: defaults for jruby.home, I see a couple different use cases here:
  1. People will either extract or install from a full distro, add $JRUBY_HOME/bin to their path and just use the jruby launcher script. In this case, jruby.home will always be determined by the script and passed on the command-line, so the default won't matter
  2. People will run with just the complete jar, maybe using some sort of --command= arg as you propose. In this case, unless jruby.home is specified, there should be someplace consistent that doesn't get in the way. If we default it to "user.dir" or some relative path to it, consistent invocation will require always running from that directory. I think this could get confusing.
  3. Embedded usages that still want to use rubygems. In this case, the embedding code should either set "jruby.home" (or possibly use IRuby#setJRubyHome, yet to be created, or some RubySetup struct like you propose), or it could just fall back to the default directory. Examples of ways I plan to use this soon are to create a maven jruby-rake-plugin to allow extending maven builds with bits of rake script. The embedded interpreter will need to download and cache a rake gem install, preferably without user intervention, and it would be nice to be able to re-use that gem install without cluttering PWD or having to re-install it every time.
Since I was aiming for something portable and not disruptive (e.g, requiring root/admin access to install in some shared directory), I thought putting it in a dot-named directory under ~/ best met these needs. If you think it's too magic, feel free to weigh in.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: