ruby:未定义的方法`>>' for“\ x0F”:String(NoMethodError)

时间:2013-01-31 21:44:20

标签: ruby redmine fastcgi

使用Apache和FastCGI访问我的Redmine安装时遇到这样的错误。可能是什么原因?

/usr/local/rvm/rubies/ruby-1.9.3-p374/lib/ruby/gems/1.9.1/gems/fcgi-0.8.8/lib/fcgi.rb:454:in `read_length': undefined method `>>' for "\x0F":String (NoMethodError)
        from /usr/local/rvm/rubies/ruby-1.9.3-p374/lib/ruby/gems/1.9.1/gems/fcgi-0.8.8/lib/fcgi.rb:448:in `read_pair'
        from /usr/local/rvm/rubies/ruby-1.9.3-p374/lib/ruby/gems/1.9.1/gems/fcgi-0.8.8/lib/fcgi.rb:441:in `parse_values'
        from /usr/local/rvm/rubies/ruby-1.9.3-p374/lib/ruby/gems/1.9.1/gems/fcgi-0.8.8/lib/fcgi.rb:435:in `parse'
        from /usr/local/rvm/rubies/ruby-1.9.3-p374/lib/ruby/gems/1.9.1/gems/fcgi-0.8.8/lib/fcgi.rb:195:in `read_record'
        from /usr/local/rvm/rubies/ruby-1.9.3-p374/lib/ruby/gems/1.9.1/gems/fcgi-0.8.8/lib/fcgi.rb:126:in `next_request'
        from /usr/local/rvm/rubies/ruby-1.9.3-p374/lib/ruby/gems/1.9.1/gems/fcgi-0.8.8/lib/fcgi.rb:116:in `session'
        from /usr/local/rvm/rubies/ruby-1.9.3-p374/lib/ruby/gems/1.9.1/gems/fcgi-0.8.8/lib/fcgi.rb:104:in `each_request'
        from /usr/local/rvm/rubies/ruby-1.9.3-p374/lib/ruby/gems/1.9.1/gems/fcgi-0.8.8/lib/fcgi.rb:36:in `each'
        from /usr/local/rvm/rubies/ruby-1.9.3-p374/lib/ruby/gems/1.9.1/gems/rack-1.4.4/lib/rack/handler/fastcgi.rb:27:in `run'
        from /var/www/redmine/public/dispatch.fcgi:21:in `<main>'

错误中提到的行如下(带行号),它是fcgi.rg文件的一个片段:

453   def self::read_length(buf)
454     if buf[0] >> 7 == 0
455     then buf.slice!(0,1)[0]
456     else buf.slice!(0,4).unpack('N')[0] & ((1<<31) - 1)
457     end
458   end

谢谢, 标记

1 个答案:

答案 0 :(得分:1)

好吧,我不确切知道发生了什么,但错误本身告诉你buf [0]是一个字符串,它不响应按位移位运算符(&gt;&gt;)。 / p>

我不确定这是否是100%正确的调试方法,但是如果你尝试解压缩该字符串,你会得到它的十进制值:

irb(main):053:0> "\x0F".unpack "c"
=> [15]

如果你在http://www.asciitable.com/看一看,显然这是“转变”角色。因此,不知何故,缓冲区会读取“移入”字符,当它试图对该字符进行逐位移位时,ruby正在抱怨。

我会检查它正在处​​理的文件,看看那里是否有任何可疑或非法字符。