'require': no such file to load -- gtk2

Hello everyone,

when I try to run this sample program:

#!/usr/bin/ruby

ZetCode Ruby GTK tutorial

This program centers a window on

the screen

author: jan bodnar

website: www.zetcode.com

last modified: April 2009

require ‘gtk2’

class RubyApp < Gtk::Window
def initialize
super

    set_title "Center"
    signal_connect "destroy" do
        Gtk.main_quit
    end

    set_default_size 250, 200
    set_window_position Gtk::Window::POS_CENTER

    show
end

end

Gtk.init
window = RubyApp.new
Gtk.main

I get error :

/home/giovi/NetBeansProjects/center/lib/main.rb:12:in `require’: no such
file to load – gtk2 (LoadError)
from /home/giovi/NetBeansProjects/center/lib/main.rb:12

Does anyone now why? I looked up in Synaptic if package gtk2 is
installed
but I can not find it there.

Thanx for your help, regards
Giovanni

On Tue, 2011-01-11 at 19:34 +0100, Giovanni Alverà wrote:

file to load – gtk2 (LoadError)
from /home/giovi/NetBeansProjects/center/lib/main.rb:12

Does anyone now why? I looked up in Synaptic if package gtk2 is
installed but I can not find it there.

You probably need to install the ‘libgtk2-ruby’ package.

Cheers
Grant

Or, better, the gtk2 gem, with

sudo gem install gtk2

Andrea

Andrea D. wrote in post #974195:

Or, better, the gtk2 gem, with

sudo gem install gtk2

Andrea

Thank you Andrea, but when I type what you
sad that’s what I get…

[email protected]:~$ sudo gem install gtk2
[sudo] password for giovi:
sudo: gem: command not found
[email protected]:~$

confused :S

I get a bit on with it.

I uninstalled package ruby1.8 and installed
ruby1.8-dev instead (the first one is missing
a few important files as suggested in topic
http://railsforum.com/viewtopic.php?id=22116)

I then installed RubyGems (vers. 1.3.5) with Synaptic.

I finally typed in a terminal:

sudo gem install gtk2

and installation went fine.
Anyway when I compile the program the
error arises again.

Grant McLean wrote in post #974023:

On Tue, 2011-01-11 at 19:34 +0100, Giovanni Alverà wrote:

file to load – gtk2 (LoadError)
from /home/giovi/NetBeansProjects/center/lib/main.rb:12

Does anyone now why? I looked up in Synaptic if package gtk2 is
installed but I can not find it there.

You probably need to install the ‘libgtk2-ruby’ package.

Cheers
Grant

I looked at package ‘libgtk2-ruby’ with Synaptic
and I already have it installed (libgtk2-ruby1.8).

Thank you anyway :slight_smile: