Making Sinatra work with JRuby and the Warbler

advertisements

I'm using the following config/warble.rb in my hello-world-style application:

Warbler::Config.new do |config|
  config.dirs = %w(app config tmp gems views)
  config.includes = FileList["hello.rb"]
  config.gems = ["sinatra"]
  config.gem_dependencies = true
end

Now when I run jruby -S warble this is the error message:

warble aborted!
uninitialized constant Warbler::Jar::Pathname
org/jruby/RubyModule.java:2526:in `const_missing'

Can anyone help me out with it? The application runs without problems when executed directly so it looks like I have all the required gems installed.

Environment:

  • JRuby 1.6.1 (same with 1.5.6)
  • Sinatra 1.2.6
  • Warbler 1.3.0
  • Windows XP
  • Ubuntu 10.04.1

I've found a workaround for this that works with both ruby and jruby.

Instead of specifying the gems inside config/warble.rb I've installed the Bundler gem and created Gemfile in the root folder of my application with the following content:

source :rubygems
gem "sinatra"

With that removed from the config/warble.rb file the actual content of this file looks like this:

Warbler::Config.new do |config|
  config.includes = FileList["hello.rb"]
end

To summarize:

  • gems go into the Gemfile
  • application files go into the config/warble.rb file