customink / stoplight

Hook it up to your builds and see their status from anywhere in the room
70 stars 24 forks source link

ERROR NoMethodError: undefined method `write' #14

Closed tonivdv closed 12 years ago

tonivdv commented 12 years ago

Hi,

I got following stacktrace when trying to run the server:

[2012-09-25 08:34:26] INFO  WEBrick 1.3.1
[2012-09-25 08:34:26] INFO  ruby 1.8.7 (2010-01-10) [i486-linux]
[2012-09-25 08:34:31] INFO  WEBrick::HTTPServer#start: pid=23823 port=9292
10.0.0.51 - - [25/Sep/2012 08:34:51] "GET / HTTP/1.1" 404 435 0.0177
[2012-09-25 08:34:51] ERROR NoMethodError: undefined method `write' for #<Logger:0xb6f085f0>
        /usr/lib/ruby/gems/1.8/gems/rack-1.4.1/lib/rack/commonlogger.rb:33:in `log'
        /usr/lib/ruby/gems/1.8/gems/rack-1.4.1/lib/rack/commonlogger.rb:22
        /usr/lib/ruby/gems/1.8/gems/rack-1.4.1/lib/rack/body_proxy.rb:17:in `call'
        /usr/lib/ruby/gems/1.8/gems/rack-1.4.1/lib/rack/body_proxy.rb:17:in `close'
        /usr/lib/ruby/gems/1.8/gems/rack-1.4.1/lib/rack/lint.rb:555:in `close'
        /usr/lib/ruby/gems/1.8/gems/rack-1.4.1/lib/rack/body_proxy.rb:15:in `close'
        /usr/lib/ruby/gems/1.8/gems/rack-1.4.1/lib/rack/handler/webrick.rb:75:in `service'
        /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
        /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
        /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
        /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
        /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
        /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
        /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
        /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
        /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
        /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
        /usr/lib/ruby/gems/1.8/gems/rack-1.4.1/lib/rack/handler/webrick.rb:13:in `run'
        /usr/lib/ruby/gems/1.8/gems/rack-1.4.1/lib/rack/server.rb:265:in `start'
        /usr/lib/ruby/gems/1.8/gems/rack-1.4.1/lib/rack/server.rb:137:in `start'
        /usr/lib/ruby/gems/1.8/gems/rack-1.4.1/bin/rackup:4
        /usr/bin/rackup:23:in `load'
        /usr/bin/rackup:23

Any ideas what it could be?

Ruby = 1.9.1

RubyGems = 1.8.24

cheers

tonivdv commented 12 years ago

Hmm, I just see in the stack that it uses ruby 1.8.7 :s ... although I installed 1.9.x ...

It's still early so I suppose I'm not yet waken :-/

Sorry 'bout that

tonivdv commented 12 years ago

Now I installed (I think) everything correctly, but I get same stacktrace :s

[2012-09-25 09:16:03] INFO  WEBrick 1.3.1
[2012-09-25 09:16:03] INFO  ruby 1.9.3 (2012-04-20) [i686-linux]
[2012-09-25 09:16:03] INFO  WEBrick::HTTPServer#start: pid=18617 port=9292
10.0.0.51 - - [25/Sep/2012 09:16:23] "GET / HTTP/1.1" 404 435 0.0352
[2012-09-25 09:16:23] ERROR NoMethodError: undefined method `write' for #<Logger:0xaec2d90>
        /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/commonlogger.rb:33:in `log'
        /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/commonlogger.rb:22:in `block in call'
        /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/body_proxy.rb:17:in `call'
        /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/body_proxy.rb:17:in `close'
        /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/lint.rb:555:in `close'
        /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/body_proxy.rb:15:in `close'
        /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/handler/webrick.rb:75:in `service'
        /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
        /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
        /usr/local/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
10.0.0.51 - - [25/Sep/2012 09:16:28] "GET /favicon.ico HTTP/1.1" 404 446 0.0010
[2012-09-25 09:16:28] ERROR NoMethodError: undefined method `write' for #<Logger:0xaec2d90>
        /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/commonlogger.rb:33:in `log'
        /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/commonlogger.rb:22:in `block in call'
        /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/body_proxy.rb:17:in `call'
        /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/body_proxy.rb:17:in `close'
        /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/lint.rb:555:in `close'
        /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/body_proxy.rb:15:in `close'
        /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/handler/webrick.rb:75:in `service'
        /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
        /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
        /usr/local/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
willdurand commented 12 years ago

There is a real issue here, and I already experienced it with different ruby versions (> 1.9.0). Here is my patch:

diff --git a/config/boot.rb b/config/boot.rb
index cbc1e5e..036429e 100644
--- a/config/boot.rb
+++ b/config/boot.rb
@@ -15,5 +15,6 @@ Rabl.register!
 require 'application'

 require 'logger'
-$logger = Logger.new('log/application.log')
+class ::Logger; alias_method :write, :<<; end
+$logger = ::Logger.new('log/application.log')
 use Rack::CommonLogger, $logger

I extended the Logger class to handle the write method:

class ::Logger; alias_method :write, :<<; end
$logger = ::Logger.new('log/application.log')

It seems to be a common error with Sinatra applications, see: http://stackoverflow.com/questions/2239240/use-rackcommonlogger-in-sinatra.

@sethvargo your input on that? Thank you.

tonivdv commented 12 years ago

I confirm that @willdurand fix/hack does the trick. thx.

sethvargo commented 12 years ago

@willdurand Can you submit a PR?

sethvargo commented 12 years ago

Fixed in 74a111fdc6816c347cad56b31b26788170e7991d