I am starting to learn the very basics of ruby on my iMac running Leopard.
The version that is now on my system is ruby 1.8.6
But, I independently also installed ( via MacPorts ) ruby 1.9 because that corresponds to the latest "PickAxe" book.
The installation location for ruby 1.8.6 is in /usr/bin/ruby The installation location for ruby 1.9.1 is in /opt/local/bin ( installed there when I used MacPorts )
My question has to do with an error message related to the require 'tk' statement in following fairly standard example, which is in the file HelloWorld.rb
require 'tk'
root = TkRoot.new { title "Hello world" }
TkLabel.new(root) do
text 'Hello world!'
end
Tk.mainloop
When I invoke the command ruby HelloWorld.rb I get the results I expect; the program runs.
However, when I invoke the command ruby1.9 HelloWorld.rb I get the error message
HelloWorld.rb:1:in require': no such file to load -- tk (LoadError)
from HelloWorld.rb:1:in
'
I have been searching the web and various postings but so far have not been able to find a clear explanation of what I need to do to make ruby1.9 be able to find tk when using the require 'tk' statement.
Does it have to do with running the gem1.9 command ( which is also in /opt/local/bin )?
I have tried invoking sudo gem1.9 install tk but that results in an error message ERROR: could not find gem tk locally or in a repository
Any suggestions would be greatly appreciated.