koraktor / rubikon

A simple to use, yet powerful Ruby framework for building console-based applications.
http://koraktor.github.com/rubikon
BSD 3-Clause "New" or "Revised" License
93 stars 2 forks source link

Exception on sample application #15

Closed rurounijones closed 13 years ago

rurounijones commented 13 years ago

Just downloaded rubikon to give it a go. when I run it I get the following output

Hello World!
/home/user/.gem/ruby/1.8/gems/rubikon-0.5.1/lib/rubikon/application/instance_methods.rb:357:in `rewind': Illegal seek (Errno::ESPIPE)
    from /home/user/.gem/ruby/1.8/gems/rubikon-0.5.1/lib/rubikon/application/instance_methods.rb:357:in `reset'
    from /home/user/.gem/ruby/1.8/gems/rubikon-0.5.1/lib/rubikon/application/instance_methods.rb:116:in `call'
    from /home/user/.gem/ruby/1.8/gems/rubikon-0.5.1/lib/rubikon/application/instance_methods.rb:116:in `run'
    from /home/user/.gem/ruby/1.8/gems/rubikon-0.5.1/lib/rubikon/application/class_methods.rb:39:in `call'
    from /home/user/.gem/ruby/1.8/gems/rubikon-0.5.1/lib/rubikon/application/class_methods.rb:39
    from ./processing.rb:55

Code

require 'rubygems'
require 'rubikon'
class Processing < Rubikon::Application::Base
  default do
    puts 'Hello World!'
  end
end

Rubikon 0.5.1 ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux] Kubuntu Linux 10.04

koraktor commented 13 years ago

Rubikon rewinds the output stream of the application when resetting. This allows using other streams like a StringIO to be used (e.g. in the tests).

Your example runs on MacOS with almost all Ruby interpreters I tested against - except for MacRuby.

So it seems like Linux doesn't like rewinding $stdout. So you could try changing line 357 of /home/user/.gem/ruby/1.8/gems/rubikon-0.5.1/lib/rubikon/application/instance_methods.rb from:

ostream.rewind

to

ostream.rewind if ostream.is_a? StringIO || !ostream.stat.chardev?

This should fix this problem. I should set up a VM and start testing under Linux, too.

rurounijones commented 13 years ago

Yep, that fixed it. Thank you very much!

It has just occurred to me that while I develop on Linux this particular app will be run on Windows so I shall test there later and raise any issues I find.