【问题标题】:Getting Sinatra to work with JRuby and Warbler让 Sinatra 与 JRuby 和 Warbler 一起工作
【发布时间】:2011-08-20 22:14:20
【问题描述】:

我在我的 hello-world-style 应用程序中使用以下 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
  • 莺 1.3.0
  • Windows XP
  • Ubuntu 10.04.1

【问题讨论】:

    标签: sinatra jruby warbler


    【解决方案1】:

    我已经找到了一种适用于 ruby​​ 和 jruby 的解决方法。

    我没有在 config/warble.rb 中指定 gem,而是安装了 Bundler gem,并在我的应用程序的根文件夹中创建了 Gemfile,其内容如下:

    source :rubygems
    gem "sinatra"
    

    从 config/warble.rb 文件中删除后,该文件的实际内容如下所示:

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

    总结一下:

    • gems 进入 Gemfile
    • 应用程序文件进入 config/warble.rb 文件

    【讨论】:

      【解决方案2】:

      事实证明,warbler 中有一个明显的错误,阻止此功能在 jruby 1.6.1 和 ruby​​ 1.8.7 下工作(不知道其他版本,因为我没有测试它)。

      查看这里以快速解决问题:

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

      【讨论】:

        猜你喜欢
        • 2012-11-20
        • 2013-05-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-14
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多