views:

77

answers:

1

it seems that Ruby GTK apps are unable to run in nongraphical environment.. while python apps are able to.

oversimplified examples (even without the gtk main loop), demonstrating this behavior:

gtktest.py:

#! /usr/bin/python
import gtk
print('the end')

gtktest.rb:

#! /usr/bin/ruby
require "gtk2"
puts('the end')

X window environment:

$ ./gtktest.py
the end
$ ./gtktest.rb
the end

non X environment:

$ ./gtktest.py
/usr/lib/pymodules/python2.5/gtk-2.0/gtk/__init__.py:57: GtkWarning: could not open display
  warnings.warn(str(e), _gtk.Warning)
the end

$ ./gtktest.rb
/usr/lib/ruby/1.8/gtk2.rb:12:in `init': Cannot open display:   (Gtk::InitError)
    from /usr/lib/ruby/1.8/gtk2.rb:12
    from ./gtktest.rb:2:in `require'
    from ./gtktest.rb:2

as you can see, python version runs succesfully with a warning, ruby one fails immediately on gtk importing (python one works even with a gtk main loop, with VTE terminal doing some text processing)

is someone aware of a possibility do have those ruby gtk apps running in non-X ?

environment: debian squeeze, python-gtk2, libgtk2-ruby

+1  A: 

Yes you can, setup Xvfb.

ChristopheD
thanks, it's the way, how to hack it. but i wonder, if there's a way, how to force the ruby gtk to not depend on X strictly, as python gtk does not
mykhal