需要Sinatra gem时出错

时间:2010-05-02 01:05:22

标签: ruby linux rubygems sinatra ubuntu-9.10

我很难让Sinatra在我的本地设置上运行,Ubuntu Karmic 9.10。当我需要'sinatra'时抛出的错误是:

NoMethodError: undefined method `[]' for nil:NilClass
from /usr/local/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:891:in `compile'
from /usr/local/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:883:in `gsub'
from /usr/local/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:883:in `compile'
from /usr/local/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:856:in `route'
from /usr/local/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:838:in `get'
from /usr/local/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:1077
from /usr/local/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:929:in `configure'
from /usr/local/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:1076
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra.rb:4
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from (irb):2
from :0

我试过了:

  • 卸载/重新安装Sinatra
  • 更新所有宝石
  • 确保所有依赖项存在(机架)

有什么想法吗?非常感谢您的时间和帮助!

1 个答案:

答案 0 :(得分:1)

这个问题显然只会在Linux上出现1.8-head。它与正则表达式匹配有关。如果您查看代码:path/((:\w+)|[\*#{special_chars.join}])/匹配,但$2nil,即使它应该是字符串。

我建议暂时改用你的ruby版本。