Wednesday, January 31, 2007

The End is Nigh: Help Squash Rails Bugs

My friends, the end of the road is in sight for official Rails support.

Tom, Ola, and I have been working over the past week to get remaining Rails issues wrapped up. As a result of our efforts:

  • ActionPack is now "practically" 100% working, minus a test or two we can't support and a few tests that are broken or that run fine in isolation (it would be nice to know *why* those fail)
  • ActiveSupport is well above 95% passing
  • ActiveRecord is in the 90% range passing with MySQL and in the 80% range with Derby
The remaining modules are still yet to be worked, but they are mostly in high % as well: ActionWebService, ActionMailer, Railties

So here is a set of instructions on how YOU, dear reader, can help round out JRuby's support for Ruby on Rails.
  1. Getting a testbed set up
    1. Update JRuby trunk (http://svn.codehaus.org/jruby/trunk/jruby), build it (ant clean jar), love it
    2. Install Rake (gem install rake)
    3. Fetch Rails 1.2.1 from Rails SVN at http://dev.rubyonrails.org/svn/rails/tags/rel_1-2-1/

  2. Running the tests
    1. From within the module under test (like activesupport/ or actionmailer/) just run "rake". All tests should execute and a report should be provided at the end. You can usually run tests individually as well, although a few depend on the side-effects of previous tests.
    2. ActiveRecord requires some additional setup; I'll update this post with Tom's instructions and patches shortly.

  3. Reporting issues
    1. Reporting failures in Rails is good
    2. Reporting reduced test cases or clear explanations for failures in Rails is better
    3. Reporting reduced test cases and including patches for failures in Rails is BEST
    4. Don't forget to check if your issue has already been reported, and please sync up on the mailing list while you're working
    5. Patches will probably not be accepted without a reusable test case. We're trying to grow our regression suite as a result of this work.
    6. JRuby's JIRA is here: http://jira.codehaus.org/browse/JRUBY

  4. Caveats, things to watch for, things to try
    1. ActiveRecord (with the AR-JDBC adapter) could use wider DB testing. We've done quite a bit of work with MySQL and Tom has been improving Derby support, but there are lots of other databases out there. Pick your favorite database, follow Tom's instructions to get up and going, and report issues (in the JRuby JIRA at least, but also report to jruby-extras project if appropriate)
    2. Railties includes code that will never run under JRuby, like its fcgi-based dispatcher tests. You should confirm with us that they're expected, and then ignore or delete them for your future runs.
    3. Rails is a very...interesting...application to debug. Feel free to ask on-list if you simply don't get something. I've seen things in Rails code no man should have to see, so I know it can be frustrating to debug at times.
We're on the home stretch now, and Rails is getting more and more solid every day. With you all helping, we should be able to finish off the remaining failures, clean up major outstanding JRuby issues, and kick out a pretty sweet "Rails-supporting" JRuby release in the next couple weeks.

Update: A couple folks pointed out that the codebase didn't compile under Java 1.4.2. That has been corrected!

Update 2: A few folks are seeing a problem installing gems related to the %p operator to printf. We're working on that, and it's a fairly minor issue, but to avoid it there's one additional step before you install rake: set the JRUBY_HOME env var to the root of your JRuby stuff.

7 comments:

Bhanu said...

Charles et al,

Great job!

I have checked out the code per your instructions and tried to compile it. I get two kinds of errors -

1) InvocationCallbackFactory.java complains that it cannot resolve symbol IllegalArgumentException. I could not find the IllegalArgumentException.java file anywhere in the code base.

2) StandardASMCompiler.java complains about the replace method on lines 137 and 963 - replace(char, char) cannot be applied to replace(String, String).

Perhaps you could refresh the code base.

Can't wait to run my Rails app on JRuby!

Thanks,
Bhanu

Jack Danger said...

Thanks for all your work!

I'm not much of a java guy but I plan to run all my apps on this tonight to do some debugging. If I can get it figured out I'll post what I get.

I can't wait for this as a deployment option!

Michael Air said...

I'm also not a java guy but I love the idea of anything that might make ruby run faster.

What I'm not clear on is If I build jruby, will rails automatically use jruby? My ruby bin path hasn't changed post build.

PJ Cabrera said...

@ Michael Air:

After you build JRuby, you need to change your path to point to the jruby bin directory. If you followed install instructions and set $JRUBY_HOME appropriately, this is done with:

export $PATH = $JRUBY_HOME / bin : $PATH

(remove extra spaces I added for readability).

The command above assumes you're in some sort of Unix environment. If on Windows, it's :

PATH = %JRUBY_HOME% \ bin ; %PATH%

(again, remove extra spaces I added for readability)

Changing the path will make sure that gem, ruby, and a few other commands are run by jruby instead of by your "normal" Ruby install.

PJ Cabrera said...

Good job with the increasing support for Rails! I'll be checking out the trunk and will see how I can help with the test coverage. Perhaps I can help improve the Postgres, Derby and SQlite support in AR-JDBC (I can only help test FOSS DBs, as I don't have and won't use Oracle, DB2, MS SQL.)

I have been using Rails for over a year, and I haven't dug in deep into the Rails code itself. Might be interesting and educational. :-)

Leo said...

Hi,

Upon executing gem i get the following exception:

java.lang.NoSuchMethodError: java.lang.Character.isWhitespace(I)Z
at org.jruby.RubyString.stripInternal(RubyString.java:2464)


Any ideas here on whats going on ?

Greetings,
Leo

James Crisp said...

Hi, I'm really looking forward to using JRuby and Rails.. but have come across a little hiccup. When getting the source in step 1.1, I get the following error:

Error: URL 'svn://rubyforge.org/var/svn/bfts/bfts/trunk' doesn't exist

half way through getting the files.

Have I done something silly?

Thanks very much,
James