# Installing Tk for Ruby on OS X

**URL:** <https://www.ruby-forum.com/t/installing-tk-for-ruby-on-os-x/70291>\
**Category:** Ruby\
**Created:** [February 19, 2006, 3:55am UTC](https://www.ruby-forum.com/t/installing-tk-for-ruby-on-os-x/70291 "2006-02-19T03:55:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 19, 2006, 3:55am UTC](https://www.ruby-forum.com/t/installing-tk-for-ruby-on-os-x/70291/1 "2006-02-19T03:55:45Z")

</div>

Hi,

I tried to run the one line script tk.rb

require ‘tk’

and saw the following error

$ ruby tk.rb  
/usr/local/lib/ruby/1.8/tk.rb:7:in `require': No such file to load -- tcltklib (LoadError) from /usr/local/lib/ruby/1.8/tk.rb:7 from tk.rb:1:in`require’  
from tk.rb:1

I don’t know if it matters but I can run the following command without  
error

$ tclsh  
%

What do I do? Do I install tk as a gem?

Thanks,  
Peter

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 19, 2006, 3:58am UTC](https://www.ruby-forum.com/t/installing-tk-for-ruby-on-os-x/70291/2 "2006-02-19T03:58:47Z")

</div>

I found this site

> **[Tcl/Tk Aqua Batteries-Included](https://sourceforge.net/projects/tcltkaqua/)**
>
> Download Tcl/Tk Aqua Batteries-Included for free. Tcl/Tk Aqua Batteries-Included is a binary distribution of the Mac OS X native Tcl/Tk and many popular extensions.

but I don’t want to use tk that is specific to aqua. I want to make a  
portable gui (Windows, Linux, OS X, …)

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 19, 2006, 4:44am UTC](https://www.ruby-forum.com/t/installing-tk-for-ruby-on-os-x/70291/3 "2006-02-19T04:44:10Z")

</div>

On Sun, 2006-02-19 at 11:58 +0900, removed\_email\_address@domain.invalid wrote:

> I found this site
> 
> [http://tcltkaqua.sourceforge.net/](http://tcltkaqua.sourceforge.net/)
> 
> but I don’t want to use tk that is specific to aqua. I want to make a  
> portable gui (Windows, Linux, OS X, …)

I’ve not used TclTkAqua, but doesn’t the Tk interface just wrap the  
widgets around the native MacOSX widget set? So it would be okay to  
create an application for Tk, and use it on other platforms.

Also, In other recent threads, you might want to check out

[http://tktable.sourceforge.net/tile/](http://tktable.sourceforge.net/tile/)  
Latest Ruby 1.8.4 contains a method to wrap the Tk API to Tile widgets,  
see the thread located at

[http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/180329](http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/180329)  
Skip ahead of the GTK/2 talk and read the Tk portion

Tsume

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 19, 2006, 5:38am UTC](https://www.ruby-forum.com/t/installing-tk-for-ruby-on-os-x/70291/4 "2006-02-19T05:38:49Z")

</div>

On Feb 18, 2006, at 11:03 PM, removed\_email\_address@domain.invalid wrote:

> I’m having trouble using even this apparently easy to use tk aqua  
> binary. Arg. Shouldn’t using Tk be extreamly easy in the Ruby  
> world? Is  
> there a catch?

The catch is that the magic Aqua Tk works very well with the Apple  
installed ruby. I don’t know how hard it is to get it to work in a  
self compiled ruby. The default tk with the source ruby distribution  
wants an X server running and doesn’t look native

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 19, 2006, 5:05am UTC](https://www.ruby-forum.com/t/installing-tk-for-ruby-on-os-x/70291/5 "2006-02-19T05:05:21Z")

</div>

I’m having trouble using even this apparently easy to use tk aqua  
binary. Arg. Shouldn’t using Tk be extreamly easy in the Ruby world? Is  
there a catch?

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 19, 2006, 2:49pm UTC](https://www.ruby-forum.com/t/installing-tk-for-ruby-on-os-x/70291/6 "2006-02-19T14:49:50Z")

</div>

removed\_email\_address@domain.invalid wrote:

> tcltklib (LoadError)  
> from /usr/local/lib/ruby/1.8/tk.rb:7  
> from tk.rb:1:in `require’  
> from tk.rb:1

Obviously Ruby’s Tk wrapper isn’t finding the library.  
Did you install Ruby on the Mac yourself?  
Which version of Mac OS X have you?

> I don’t know if it matters but I can run the following command without  
> error
> 
> $ tclsh  
> %
> 
> What do I do? Do I install tk as a gem?

First try the Tcl shell with Tk built in, it’s called ‘wish’.

Paste this into wish (or put it in a file e.g. called ‘hello’, and  
execute ‘wish hello’):  
button .b -text “Hello, world!” -command exit  
pack .b

You should get a small window with a 'Hello, world" button.

On my Mac OS X 10.4, the pre-installed Ruby works with Tk (which is  
also installed), so …

Can you revert to the version that came pre-installed on the Mac  
(/usr/bin/ruby) and try the little ‘hello world’ example? That will  
tell you if you have the right pieces installed, and if Tk is able to  
cooperate.

This may be good enough for now, but if not, the build method  
recommended by the Ruby on Rails book is at:  
[http://tech.rufy.com/articles/2005/05/01/complete-fix-for-ruby-on-mac-os-x-10-4-tiger](http://tech.rufy.com/articles/2005/05/01/complete-fix-for-ruby-on-mac-os-x-10-4-tiger)

I haven’t tried that yet, but will will later today (I may need to use  
different versions of Ruby for a project).

HTH GB-)
