让 Sinatra 与 JRuby 和 Warbler 一起工作
我在 hello-world 风格的应用程序中使用以下 config/warble.rb:
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
现在,当我运行 jruby -S warble 时,这是错误消息:
warble aborted!
uninitialized constant Warbler::Jar::Pathname
org/jruby/RubyModule.java:2526:in `const_missing'
谁能帮我解决这个问题吗?直接执行时应用程序运行没有问题,所以看起来我已经安装了所有必需的 gem。
环境:
- JRuby 1.6.1(与1.5.6相同)
- Sinatra 1.2.6
- Warbler 1.3.0
- Windows XP
- Ubuntu 10.04.1
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我找到了一个适用于 ruby 和 jruby 的解决方法。
我没有在 config/warble.rb 中指定 gem,而是安装了 Bundler gem,并在应用程序的根文件夹中创建了 Gemfile,其中包含以下内容:
从 config/warble.rb 文件中删除该文件的实际内容看起来像这样:
总结一下:
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:
With that removed from the config/warble.rb file the actual content of this file looks like this:
To summarize:
事实证明,warbler 中有一个明显的错误,阻止此功能在 jruby 1.6.1 和 ruby 1.8.7 下工作(不知道其他版本,因为我没有测试它)。
看看这里的快速修复:
https://github.com/padcom/warbler/commit/ b4b24e17dee5bb98525203c82519a8901874ef81
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