M
M
Michael Galyuk2013-11-13 12:44:56
ruby
Michael Galyuk, 2013-11-13 12:44:56

How to properly install Gtk toolkit and Ruby-Gtk binding in OS X?

I don't use OS X myself, but people want to run my ruby+gtk program.

To test, we use a simple gtktest.rb example :

#!/usr/bin/env ruby
require 'gtk2'
Gtk.init
w = Gtk::Window.new('Title')
w.show_all
Gtk.main

To install ruby+gtk on OS X, the following commands are recommended:

brew install gtk+ ruby
sudo gem install gtk2

On the first command:

$ brew install gtk+
got errors:
gtk+: Unsatisfied dependency: XQuartz 2.3.6
Homebrew does not package XQuartz. Installers may be found at:
https://xquartz.macosforge.org
cairo: Unsatisfied dependency: XQuartz 
Homebrew does not package XQuartz. Installers may be found at:
https://xquartz.macosforge.org
pango: Unsatisfied dependency: XQuartz 
Homebrew does not package XQuartz. Installers may be found at:
https://xquartz.macosforge.org
Error: An unsatisfied requirement failed this build.
The site xquartz.macosforge.org was down yesterday, so the person downloaded X11 (XQuartz) from somewhere else. As a result, everything was installed, but errors appear:

$ ruby gtktest.rb
/Library/Ruby/Gems/2.0.0/gems/gtk2-2.0.2/lib/gtk2.rb:13:in `init': Cannot open display: (Gtk::InitError)
from /Library/Ruby/Gems/2.0.0/gems/gtk2-2.0.2/lib/gtk2.rb:13:in `<top>'
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `require'
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:144:in `require'
from gtktest.rb:2:in `<main>'</main></top>

Guys, tell me how to properly install ruby, gtk and ruby-gtk binding in OS X?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
relgames, 2013-11-14
@relgames

If you recently upgraded to OS X 10.9, you may need to update/reinstall XCode.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question