Sunday 3 May 2015

Installing gtk3 Ruby Gem on OS X Yosemite

As I found installing the gtk3 Ruby Gem on OS X Yosemite is a little fiddly, I thought I'd make a note of how to do it for next time so that I don't need to spend time searching the internet to found out how.

First, you need to install X-windows. That's pretty straightforward simply click on the X.11 icon in the Others collection in LaunchPad and follow the instructions.

Second, you need to install gtk+3 itself. Using HomeBrew that's straightforward:

    brew install gtk+3

Then the tricky bit. You need to help gem find the correct libffi library. I found  out how to do it thanks to the Ruby-Gnome team:

   sudo PKG_CONFIG_PATH=/usr/local/opt/libffi/lib/pkgconfig gem install gtk3

5 comments:

Unknown said...

Just want to thank you for posting each step of your "Ruby GUI app on Raspberry PI" adventure. I have just recently started down the same thorny path and your documentation of all the little gotchas and snags have helped me tremendously!

Peter W A Wood, Programmer said...

Thank you. I've just seen your comment. I must have something setup incorrectly as I don't seem to receive any notification of a comment waiting for moderation.

Unknown said...

Ah no worries! You may be saddened to know that I ran into some issues with getting gtk3 going on my mac that resulted in me giving up and just using Python... I know - Python... eww (as a Rubyist through and through it definitely made me a little sad)

Peter W A Wood, Programmer said...

May I ask what issues? There are two things that aren't good when I use GTK3 on OS X.

The first is a "deprecated" warning message on start up. I have reported this to the GTK3 so hopefully it will get fixed eventually.

The second is that Ruby crashes when you close the GTK3 app. I reported this to the GTK gem team and they have fixed the problem. The fix is not yet in the gtk3 gem but should be in the next update.

Unknown said...

the gem installs just fine (after using your env settings), but the moment I try to run a ruby file that has a "require 'gtk3'" in it i get the following exception:

https://gist.github.com/jspillers/02ac0614c03b5723f641

Looks like its just some path issues, but at the time i ran into it I didn't have time to try to debug further. Not sure what the solution is yet.