# Where is Ruby 1.9 'TK' library?

**URL:** <https://www.ruby-forum.com/t/where-is-ruby-1-9-tk-library/183636>\
**Category:** Ruby\
**Created:** [February 17, 2010, 7:36pm UTC](https://www.ruby-forum.com/t/where-is-ruby-1-9-tk-library/183636 "2010-02-17T19:36:05Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [February 17, 2010, 7:36pm UTC](https://www.ruby-forum.com/t/where-is-ruby-1-9-tk-library/183636/1 "2010-02-17T19:36:05Z")

</div>

Just installed Ruby 1.9 and tried to run one of my TK applications that  
works using Ruby 1.8. There doesn’t appear to be a ‘TK’ library in Ruby  
1.9. Where/how can I get and install the ‘TK’ library?

–Alex

---

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [February 17, 2010, 8:08pm UTC](https://www.ruby-forum.com/t/where-is-ruby-1-9-tk-library/183636/2 "2010-02-17T20:08:07Z")

</div>

On Wed, Feb 17, 2010 at 12:36 PM, Alex DeCaria  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Just installed Ruby 1.9 and tried to run one of my TK applications that  
> works using Ruby 1.8. There doesn’t appear to be a ‘TK’ library in Ruby  
> 1.9. Where/how can I get and install the ‘TK’ library?
> 
> –Alex

See the recent (within the past two days) threads about Tk here. It  
sounds like you’re using the Windows RubyInstaller, which (as I just  
found out) doesn’t include Tk or Tk bindings.

---

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [February 17, 2010, 10:13pm UTC](https://www.ruby-forum.com/t/where-is-ruby-1-9-tk-library/183636/3 "2010-02-17T22:13:57Z")

</div>

On Feb 17, 7:36 pm, Alex DeCaria [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Just installed Ruby 1.9 and tried to run one of my TK applications that  
> works using Ruby 1.8. There doesn’t appear to be a ‘TK’ library in Ruby  
> 1.9. Where/how can I get and install the ‘TK’ library?

The Tk bindings in RubyInstaller has not been included.

The reason for that is simple: finding the proper Tk package, manage  
to automate the unpacking and verify that Ruby does the good job in  
picking it up during compilation takes time.

All the above thing is what we call a build recipe. At this time,  
nobody wrote it. But I’m open to add extensions if someone takes the  
stab and create the recipe \*using rake tasks) to build it.

The repository is here:

[http://github.com/oneclick/rubyinstaller/](http://github.com/oneclick/rubyinstaller/)

Once implemented and tested, just send a pull request and will get  
those changes tested and then merged.

Is extremely important the Tk package Ruby will links against could be  
unpacked, _not installed_. Installation sometimes requires certain  
levels of right that some users don’t have when working with the build  
recipes.

Also, because the recipes should document the process, not hide a  
dependency or specific of a version outside the repository.

Hope this shed some light on this.

Regards,

---

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [February 17, 2010, 11:38pm UTC](https://www.ruby-forum.com/t/where-is-ruby-1-9-tk-library/183636/4 "2010-02-17T23:38:49Z")

</div>

On Wed, Feb 17, 2010 at 3:10 PM, Luis L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> to automate the unpacking and verify that Ruby does the good job in  
> Once implemented and tested, just send a pull request and will get  
> Hope this shed some light on this.  
> Luis, is it possible at all to _add_ Tk bindings to a copy of Ruby  
> that has already been installed via RubyInstaller?

---

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [February 18, 2010, 12:40am UTC](https://www.ruby-forum.com/t/where-is-ruby-1-9-tk-library/183636/5 "2010-02-18T00:40:06Z")

</div>

> Luis, is it possible at all to _add_ Tk bindings to a copy of Ruby  
> that has already been installed via RubyInstaller?

Funny you ask.

[http://wiki.github.com/rdp/ruby\_tutorials\_core/tk](http://wiki.github.com/rdp/ruby_tutorials_core/tk)

has some info on it (I’ve had success installing tk\_as\_gem for 1.9.1  
mingw).

-rp

---

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [February 18, 2010, 1:09am UTC](https://www.ruby-forum.com/t/where-is-ruby-1-9-tk-library/183636/6 "2010-02-18T01:09:32Z")

</div>

On Wed, Feb 17, 2010 at 5:40 PM, Roger P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > Luis, is it possible at all to _add_ Tk bindings to a copy of Ruby  
> > that has already been installed via RubyInstaller?
> 
> Funny you ask.
> 
> [http://wiki.github.com/rdp/ruby\_tutorials\_core/tk](http://wiki.github.com/rdp/ruby_tutorials_core/tk)
> 
> has some info on it (I’ve had success installing tk\_as\_gem for 1.9.1  
> mingw).

Wow, nice! Only… how do I compile the extension to take its Tcl/Tk  
files from a non-default directory? I tried:  
gem install tk\_as\_gem – --with-tcl-dir=‘C:/Documents and  
Settings/echristopherson/My Documents/Development/Tcl’  
–with-tk-dir=‘C:/Documents and Settings/echristopherson/My  
Documents/Development/Tcl’

(I don’t have permission to install in C:.)

---

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [February 18, 2010, 1:13am UTC](https://www.ruby-forum.com/t/where-is-ruby-1-9-tk-library/183636/7 "2010-02-18T01:13:56Z")

</div>

> Wow, nice! Only… how do I compile the extension to take its Tcl/Tk  
> files from a non-default directory? I tried:  
> gem install tk\_as\_gem – --with-tcl-dir=‘C:/Documents and  
> Settings/echristopherson/My Documents/Development/Tcl’  
> –with-tk-dir=‘C:/Documents and Settings/echristopherson/My  
> Documents/Development/Tcl’

Did you add the bin dir into your path?  
-r

---

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [February 18, 2010, 4:59am UTC](https://www.ruby-forum.com/t/where-is-ruby-1-9-tk-library/183636/8 "2010-02-18T04:59:51Z")

</div>

> ‘ERROR: Error installing tk\_as\_gem:  
> ERROR: Failed to build native extension.’
> 
> Any idea what may be wrong? I have both Tcl and Ruby 1.9 installed on  
> my C: drive.

My first guess is that you don’t have the devkit installed (if gcc  
–version works then you do, though). We’ll probably need more info,  
like put your mkmf.log output into a pastie and post the link back here  
or what not.  
GL!  
-r

---

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [February 18, 2010, 2:34am UTC](https://www.ruby-forum.com/t/where-is-ruby-1-9-tk-library/183636/9 "2010-02-18T02:34:55Z")

</div>

Roger P. wrote:

> > Luis, is it possible at all to _add_ Tk bindings to a copy of Ruby  
> > that has already been installed via RubyInstaller?
> 
> Funny you ask.
> 
> [http://wiki.github.com/rdp/ruby\_tutorials\_core/tk](http://wiki.github.com/rdp/ruby_tutorials_core/tk)
> 
> has some info on it (I’ve had success installing tk\_as\_gem for 1.9.1  
> mingw).
> 
> -rp

I tried: ‘gem install tk\_as\_gem’ but get the error message

‘ERROR: Error installing tk\_as\_gem:  
ERROR: Failed to build native extension.’

Any idea what may be wrong? I have both Tcl and Ruby 1.9 installed on  
my C: drive.

–Alex

---

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [February 18, 2010, 7:52am UTC](https://www.ruby-forum.com/t/where-is-ruby-1-9-tk-library/183636/10 "2010-02-18T07:52:46Z")

</div>

On Wed, Feb 17, 2010 at 6:14 PM, Roger P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > Wow, nice! Only… how do I compile the extension to take its Tcl/Tk  
> > files from a non-default directory? I tried:  
> > gem install tk\_as\_gem – --with-tcl-dir=‘C:/Documents and  
> > Settings/echristopherson/My Documents/Development/Tcl’  
> > –with-tk-dir=‘C:/Documents and Settings/echristopherson/My  
> > Documents/Development/Tcl’
> 
> Did you add the bin dir into your path?

Yes. Still no luck. I also tried using both MSys and cmd.exe. This was  
on my work computer.

At home, I tried installing the gem from MSys and it seemed to hang  
for 30 minutes or more, so I ran gem install with --verbose the second  
time. It seems to be sitting there doing nothing at a few different  
spots, but the really long one (which never terminates that I can see)  
is after it runs /bin/install on a whole bunch of files, with the last  
one being ./lib/tkextlib/SUPPORT\_STATUS.

At that point, I got the message “Updating class cache with 496  
classes…”. After waiting about 20 minutes for that the first time, I  
decided to try running gem install with --no-ri and  
–no-update-sources, but it still hangs.

Places where it hangs:

1. Right after the line  
“c:/Ruby/lib/ruby/gems/1.9.1/gems/tk\_as\_gem-0.0.1/ext/lib/tkextlib/tkimg/window.rb”.  
This takes about 10 minutes here, before it actually prints out the  
remaining 42 or so files unpacked, and configures and compiles the  
extension.
2. Right after the line “/bin/install -c -m 644  
./lib/tkextlib/SUPPORT\_STATUS  
c:/Ruby/lib/ruby/gems/1.9.1/gems/tk\_as\_gem-0.0.1/lib/tkextlib”. This  
is the one that seems to hang for 40 minutes, or however long I let it  
go on.

After I kill the process, I am able to at least run a test Tk program.

While we’re on the subject, gem install --verbose lists the files that  
it’s unpacking, and part of the output is the following:

(begin)  
c:/Ruby/lib/ruby/gems/1.9.1/gems/tk\_as\_gem-0.0.1/ext/lib/tk/clipboard.rb

:/Ruby/lib/ruby/gems/1.9.1/gems/tk\_as\_gem-0.0.1/ext/lib/tk/clock.rb  
(end)

– notice that there is a blank line between clipboard.rb and  
clock.rb, and the clock.rb line starts with 😕 instead of c:/. Does  
anyone know why that would be? It seems to always happen right between  
those two lines.

---

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [February 19, 2010, 7:58pm UTC](https://www.ruby-forum.com/t/where-is-ruby-1-9-tk-library/183636/11 "2010-02-19T19:58:04Z")

</div>

On Thu, Feb 18, 2010 at 1:14 AM, Roger P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > 1. Right after the line “/bin/install -c -m 644  
> > ./lib/tkextlib/SUPPORT\_STATUS  
> > c:/Ruby/lib/ruby/gems/1.9.1/gems/tk\_as\_gem-0.0.1/lib/tkextlib”. This  
> > is the one that seems to hang for 40 minutes, or however long I let it  
> > go on.
> 
> Hangs with tk for me have typically historically meant that Tk wasn’t  
> found (I think, anyway). that for was 1.8 I’ve never seen it for 1.9,  
> though.

It did find Tk and used it to compile the extension; and things seem  
to work afterwards. Maybe part of the reason is that I was using Tk  
8.5 instead of 8.4?

> Here’s a zipped up copy of my binaries (with the gem compiled in there).  
> They might not even need the tcl binaries in the path…but probably do  
> (8.4 binaries).
> 
> [http://rubydoc.ruby-forum.com/distro/ruby191p376.tgz](http://rubydoc.ruby-forum.com/distro/ruby191p376.tgz)

Thanks. I’ll try to download 8.4 so I can try it out later.

---

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [February 18, 2010, 8:14am UTC](https://www.ruby-forum.com/t/where-is-ruby-1-9-tk-library/183636/12 "2010-02-18T08:14:19Z")

</div>

> 1. Right after the line “/bin/install -c -m 644  
> ./lib/tkextlib/SUPPORT\_STATUS  
> c:/Ruby/lib/ruby/gems/1.9.1/gems/tk\_as\_gem-0.0.1/lib/tkextlib”. This  
> is the one that seems to hang for 40 minutes, or however long I let it  
> go on.

Hangs with tk for me have typically historically meant that Tk wasn’t  
found (I think, anyway). that for was 1.8 I’ve never seen it for 1.9,  
though.

Here’s a zipped up copy of my binaries (with the gem compiled in there).  
They might not even need the tcl binaries in the path…but probably do  
(8.4 binaries).

[http://rubydoc.ruby-forum.com/distro/ruby191p376.tgz](http://rubydoc.ruby-forum.com/distro/ruby191p376.tgz)

HTH.

-rp

---

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [February 19, 2010, 8:05pm UTC](https://www.ruby-forum.com/t/where-is-ruby-1-9-tk-library/183636/13 "2010-02-19T20:05:35Z")

</div>

I got an interesting result. I was able to install tk\_from\_gem and it  
installed and worked. However, if I run my Tk application using Ruby  
1.9 it loads noticably slow (the Gui builds frame-by-frame as I watch  
it). If I run the exact same application using Ruby 1.8, it loads  
instantaneously.

I’ve attached the application I’m running (a units converter program) in  
case anyone wants to play with it. Please note it was my first attempt  
at GUI programming, so I know it’s not the best for style, etc.

–Alex

---

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [February 19, 2010, 8:42pm UTC](https://www.ruby-forum.com/t/where-is-ruby-1-9-tk-library/183636/14 "2010-02-19T20:42:04Z")

</div>

Alex DeCaria wrote:

> I got an interesting result. I was able to install tk\_from\_gem and it  
> installed and worked. However, if I run my Tk application using Ruby  
> 1.9 it loads noticably slow (the Gui builds frame-by-frame as I watch  
> it). If I run the exact same application using Ruby 1.8, it loads  
> instantaneously.

Interesting. I get the same thing with tk\_as\_gem (and approximately the  
same thing with 1.9.1 with tk “built inline” (non gem)) [1]

Wonder why it’s slower.

-rp  
[1] [http://rubydoc.ruby-forum.com/distro/ruby-1.9.1-p243-tweaked.tgz](http://rubydoc.ruby-forum.com/distro/ruby-1.9.1-p243-tweaked.tgz)

---

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [February 19, 2010, 9:21pm UTC](https://www.ruby-forum.com/t/where-is-ruby-1-9-tk-library/183636/15 "2010-02-19T21:21:47Z")

</div>

Roger, could you give some more guidance on what gem/extconf switches  
are required to get tk\_as\_gem built when Tk is installed somewhere  
other than C:\Tcl?

Also, is there anything I can do to help diagnose the hanging problem  
that happens on my other computer (which does have C:\Tcl)?

---

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [February 24, 2010, 1:50am UTC](https://www.ruby-forum.com/t/where-is-ruby-1-9-tk-library/183636/16 "2010-02-24T01:50:37Z")

</div>

On Fri, Feb 19, 2010 at 3:29 PM, Roger P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> gem install tk\_as\_gem – --with-tcl-dir=/installs/Tcl  
> –with-tk-dir=/installs/Tcl

I’ve finally had success installing tk\_as\_gem on my home Windows VM  
and my work Windows machine. It also no longer hangs for long periods  
of time. On my VM I didn’t really have to do anything to make it work,  
but on my work PC I have everything stored under My Documents since I  
can’t write to C:. Here is what helped:

1. Upgrade to the newest RubyInstaller package (1.9.1-p378). P243 had  
a bug where the compilation couldn’t finish because it had run out of  
memory (Errno::ENOMEM). Install the devkit from [rubyinstaller.org](http://rubyinstaller.org), if  
you haven’t already.
2. Run gem in a Windows command prompt (cmd) window. I never got it  
working under MSys.
3. Use “short filenames” (the ones with ~ in them) instead of any  
file/directory name with spaces. You can find out short filenames in  
cmd by running dir /x on their parent directories. I couldn’t get  
paths with spaces to work.
4. For convenience, I set a shell variable TCLDIR\_. It was set to  
C:/Docume~1/echris~1/MyDocu~1/Development/Tcl. Note that this has  
forward slashes instead of backslashes! Gcc doesn’t understand  
backslashes. (The underscore is because I had another variable TCLDIR  
with backslashes.)
5. Use the command line:  
gem install --verbose tk\_as\_gem – --with-tcl-dir=%TCLDIR%  
–with-tk-dir=%TCLDIR%

I really hope this helps someone. Roger, I don’t know if you’d be able  
to fix things so it can build with pathnames with spaces, or under  
MSys, but that’d be great. And thanks for the hard work of making this  
a gem!

---

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [February 19, 2010, 10:29pm UTC](https://www.ruby-forum.com/t/where-is-ruby-1-9-tk-library/183636/17 "2010-02-19T22:29:08Z")

</div>

> Roger, could you give some more guidance on what gem/extconf switches  
> are required to get tk\_as\_gem built when Tk is installed somewhere  
> other than C:\Tcl?

Looks like I was hard coding it to /Tcl (my bad).

Give 'er a shot now.

ex:

gem install tk\_as\_gem – --with-tcl-dir=/installs/Tcl  
–with-tk-dir=/installs/Tcl

> Also, is there anything I can do to help diagnose the hanging problem  
> that happens on my other computer (which does have C:\Tcl)?

Typically for me this has meant I don’t have tk84.dll in my path.

You can make sure it is using the whichr gem, if desired.  
c:\dev\_old\>gem install os whichr  
c:\dev\_old\>whichr tk\*.dll -a  
higher in the list is executed first  
e:\Tcl\bin\tk84.dll (is not executable)

(it should show one)  
-r

---

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [March 5, 2010, 12:23pm UTC](https://www.ruby-forum.com/t/where-is-ruby-1-9-tk-library/183636/18 "2010-03-05T12:23:40Z")

</div>

Roger P. wrote:

> > ‘ERROR: Error installing tk\_as\_gem:  
> > ERROR: Failed to build native extension.’
> > 
> > Any idea what may be wrong? I have both Tcl and Ruby 1.9 installed on  
> > my C: drive.
> 
> My first guess is that you don’t have the devkit installed (if gcc  
> –version works then you do, though). We’ll probably need more info,  
> like put your mkmf.log output into a pastie and post the link back here  
> or what not.  
> GL!  
> -r

Roger,

I’m still trying to get tk\_to\_gem to work on my 64-bit windows. I made  
sure devkit was installed, and gcc --version works. I’m getting the  
same error message. I can’t seem to locate the mkmf.log file. It  
doesn’t even seem to be created (I did a search of my entire harddrive  
and only found mkmf.log files for other installs I’ve done).

As mentioned before, it worked fine on my other (32-bit) system. Would  
there be any 64-bit issues with tk\_as\_gem?

–Alex

---

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [March 6, 2010, 1:48am UTC](https://www.ruby-forum.com/t/where-is-ruby-1-9-tk-library/183636/19 "2010-03-06T01:48:15Z")

</div>

> I’m still trying to get tk\_to\_gem to work on my 64-bit windows. I made  
> sure devkit was installed, and gcc --version works. I’m getting the  
> same error message. I can’t seem to locate the mkmf.log file. It  
> doesn’t even seem to be created (I did a search of my entire harddrive  
> and only found mkmf.log files for other installs I’ve done).

What’s the full output? Do you have 32 bit versions of tk and ruby  
installed, I assume?  
-rp

---

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [March 8, 2010, 6:03pm UTC](https://www.ruby-forum.com/t/where-is-ruby-1-9-tk-library/183636/20 "2010-03-08T18:03:14Z")

</div>

> The contents of the gem\_make.out file are just ‘C:/Ruby19/bin/ruby.exe  
> extconf.rb’

What happens if you try and run ruby extconf.rb?  
-rp

[Next page](https://www.ruby-forum.com/t/where-is-ruby-1-9-tk-library/183636.md?page=2)
