petermichaux@yahoo.com wrote:
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
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
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-)