开发者

Getting Sinatra to work with JRuby and Warbler

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:


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


As it turns out there's an obvious bug in warbler preventing this functionality to work under jruby 1.6.1 and ruby 1.8.7 (don't know about other versions because I didn't test it).

Take a look here for a quick fix:

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜