JRuby and Rake

In my quest to write nothing but Ruby code in my copious free time, I’ve begun learning JRuby, which I’m finding an ideal solution to my Java projects, such as DiffJ and DoctorJ, which are dependent on Java because they use the parser from PMD.

Likewise I am migrating my build code away from Ant, using Gradle for the soon-to-be-released DiffJ 1.2.0. Thus I began trying to use the Ant library for Rake via JRuby, but was confounded by an error for the simple Rakefile:

require 'ant'

task :greet do
  puts "hello"
% jruby -S rake /usr/bin/rake:27:in `require': no such file to load -- rake (LoadError)
	from /usr/bin/rake:27

The fix was simple. Changing my mindset was more complicated: JRuby is looking for Ruby Gems in its own directory hierarchy, not the Ruby hierarchy.

So installing the Rake gem as follows fixed the problem:

% sudo jruby -S gem install rake

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s