Tk on Snow Leopard

Sorry about posting an OS specific question here, but the Apple
support discussion groups seem to think this is a problem with Tk
bindings in Ruby, not with Snow Leopard. Makes no sense to me, but
whatever.

I’ve used Tk as my go-to GUI for Ruby for years, and love it. In
Leopard (10.5) Tk bindings worked, in Snow Leopard (10.6) I get this
error if I try to run a script with “require tk”

LoadError: no such file to load — tk

Does anyone know a good workaround? Has anyone had success getting tk
bindings to work in 10.6, e.g. with MacPorts? I haven’t tried that
approach–I wanted to find out others experience before I went through
that.

Frankly, I wish that I could replace MacOS with Linux on this hardware
(I mean replace, not run a vm) but I digress.

TIA,
Craig

On Oct 11, 2009, at 06:29 , Dudebot wrote:

Does anyone know a good workaround? Has anyone had success getting tk
bindings to work in 10.6, e.g. with MacPorts? I haven’t tried that
approach–I wanted to find out others experience before I went through
that.

Sure enough, it looks like apple didn’t ship the tk extension:

511 % find /System/Library/Frameworks/Ruby.framework/Versions/Current -
name tk.rb
512 %

The obvious workaround is to build and install your own ruby (either
yourself or via macports). That requires having the developer tools
installed so you have a C compiler. By default ruby will install into /
usr/local/ (/opt/local if macports) and that won’t be in your path.
You’ll need to either add it BEFORE /usr/bin so the stock ruby gets
overridden or rename the stock ruby.

Sure enough, it looks like apple didn’t ship the tk extension:

The obvious workaround is to build and install your own ruby

Thanks super, Ryan. I was hoping to try to avoid that, but… :slight_smile:
For those who are interested, the best instructions I found for
installing Ruby-Tk on Snow Leopard were at Dan Benjamin’s Hivelogic
site:

A virtual thank you to Dan :slight_smile:

Craig