Getting Sinatra to work with JRuby and Warbler

I use the following /warble.rb configuration in a hi-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 error message:

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

Can anyone help me with this? The application starts without problems when executed directly, so it looks like I have all the necessary stones 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
+4
source share
2 answers

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

Instead of specifying gems inside config / warble.rb, I installed the Bundler stone and created a Gemfile in the root folder of my application with the following contents:

 source :rubygems gem "sinatra" 

With the removal of the config / warble.rb file, the actual contents of this file are as follows:

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

Summarizing:

  • gems go into gemfile
  • application files are included in the config / warble.rb file
+2
source

As it turns out, an obvious error appears in warbler, which prevents this function from working under jruby 1.6.1 and ruby ​​1.8.7 (I don’t know about other versions because I did not test it).

Take a quick fix here:

https://github.com/padcom/warbler/commit/b4b24e17dee5bb98525203c82519a8901874ef81

+2
source

All Articles