Fixing Issue with JRuby 1.0 and Rails

In seeing if my post on installing Deploying Rails to Tomcat as a WAR I came across an issue with running rails under JRuby 1.0 and ActiveRecord-JDBC 0.4.

First off you still have to run the following command because the rails script file is still not set to be executable:

chmod 775 $JRUBY_HOME/bin/rails

In addition I had to change the top shebang line of the script after I got this error:

rails --version
/Applications/jruby-1.0/bin/rails: line 9: require: command not found
/Applications/jruby-1.0/bin/rails: line 10: version: command not found
/Applications/jruby-1.0/bin/rails: line 11: syntax error near unexpected token `('
/Applications/jruby-1.0/bin/rails: line 11: `if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct?
1
2
3
4
5
$ rails --version
/Applications/jruby-1.0/bin/rails: line 9: require: command not found
/Applications/jruby-1.0/bin/rails: line 10: version: command not found
/Applications/jruby-1.0/bin/rails: line 11: syntax error near unexpected token `('
/Applications/jruby-1.0/bin/rails: line 11: `if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then'

I found the fix here, but you just change the top shebang line from:

#!/Applications/jruby-1.0/bin/jruby

To:

#!/usr/bin/env jruby