cat mind > /dev/null

My random thoughts/views/reviews

*” installing – JRuby on Rails (jRoR) “

install jruby on Linux and then install rails on jruby by the following procedure. I installed it on Slackware Linux 11.0.
INSTALLING JRUBY

download jruby-bin-1.0.zip from jruby.org
copy it to the desired directory, say /opt
cd /opt
unzip jruby-bin-1.0.zip
ln -s jruby-1.0 jruby

export JRUBY_HOME=/opt/jruby
export PATH=$JRUBY_HOME/bin:$PATH

jruby commands “jruby”, “jirb”,”jrubyc”
jruby-bin-1.0.zip comes bundled with gem and rake (the modified ones which search for jruby instead of ruby)

For testing, write a program hello.rb
print “Hello World”
Now run it as,
jruby hello.rb

INSTALLING RAILS ON JRUBY

TIP: do put $JRUBY_HOME/bin in $PATH earlier as specified, so that gem command from jruby will execute, not from ruby installation (if any) on your machine

gem install rails -y
currently it will install gems of rails-1.2.3, activesupport-1.4.2, activerecord-1.15.3, actionpack-1.13.3, actionmailer-1.3.3, actionwebservice-1.2.3

now, goto your application directory, say
mkdir ~/app
cd ~/app

now,if u give the following command:
root@singularity:~/app# rails blogapp

/opt/jruby/bin/rails: line 9: require: command not found
/opt/jruby/bin/rails: line 10: version: command not found
/opt/jruby/bin/rails: line 11: syntax error near unexpected token `(‘
/opt/jruby/bin/rails: line 11: `if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then’

To resolve there are two methods:
METHOD1:
HENCE, we gave the following command instead:
jruby $JRUBY_HOME/bin/rails blogapp

METHOD2: This method took me a some time to figure out because i was unable to gauge the crux of the problem initially, but finally it was actually very simple solution to a simple problem
open $JRUBY_HOME/bin/rails file in an editor
you will find the first line is mentioned as(say), #!/opt/jruby-1.0/bin/jruby
change it to #!/usr/bin/env jruby
Now, you can give the normal command:
rails blogapp

Now,
cd blogapp
now start the server by,
jruby script/server

now access the rails page at:
* http://localhost:3000

stay tuned for more articles on jruby specific features ( not in native ruby ) and rails :-)

June 29, 2007 Posted by ashishwave | Geek, Java, Tech, jruby, ruby, technology | | 2 Comments