Problem installing TkRuby on Ubuntu 12.04

Might seem a little long, but it’s actually pretty small…

I have decided to install Tcl, Tk and tcltk libraries for ruby on Ubuntu
12.04, but I got struck in the process where there seems to be a version
conflict.

Here’s what I have done…

Firstly, I uninstalled built in ruby packages using apt-get remove
command.

Now, I installed ruby 1.9.1 using sudo apt-get install ruby1.9.1 command

Then, when I check the version using command ruby --version, it says
ruby1.9.3p0 (But, I installed 1.9.1 ??)

Then, I installed tcl8.5 and tk8.5 using sudo apt-get install tcl8.5 and
sudo apt-get install tk8.5

Then, I installed ruby libraries using sudo apt-get install
libtcltk-ruby1.9.1

Now, in the irb, when I require ‘tk’

it says:

RuntimeError: tcltklib: fail to Tk_Init(). Can’t find a usable tk.tcl in
the following directories:
/usr/share/tcltk/tcl8.5/tk8.5 /usr/lib/tk8.5
/usr/local/lib/tcltk/tk8.5 /usr/local/share/tcltk/tk8.5
/usr/lib/tcltk/tk8.5 /usr/share/tcltk/tk8.5 /lib/tk8.5 /usr/library

/usr/share/tcltk/tk8.5/tk.tcl: version conflict for package “Tk”: have
8.5.10, need exactly 8.5.11
version conflict for package “Tk”: have 8.5.10, need exactly 8.5.11
while executing
“package require -exact Tk 8.5.11”
(file “/usr/share/tcltk/tk8.5/tk.tcl” line 18)
invoked from within
“source /usr/share/tcltk/tk8.5/tk.tcl”
(“uplevel” body line 1)
invoked from within
“uplevel #0 [list source $file]”

After, when I exit irb, it shows a segmentation fault and a huge list of
process memory map, backtrace information etc. and says Aborted(core
dumped).

What just happened? Why is Tk not working? What should I do to get exact
8.5.11 version? BTW, I am running amd64 version of Ubuntu 12.04 LTS.

On 2012-05-16 13:10, Bharadwaj S. wrote:

Then, I installed tcl8.5 and tk8.5 using sudo apt-get install tcl8.5 and
sudo apt-get install tk8.5

plus the -dev packages?

Wybo D. wrote in post #1060962:

On 2012-05-16 13:10, Bharadwaj S. wrote:

Then, I installed tcl8.5 and tk8.5 using sudo apt-get install tcl8.5 and
sudo apt-get install tk8.5

plus the -dev packages?

I tried in both ways… same error in both cases. :frowning:

From: Bharadwaj S. [email protected]
Subject: problem installing TkRuby on ubuntu 12.04
Date: Wed, 16 May 2012 20:10:46 +0900
Message-ID: [email protected]

/usr/share/tcltk/tk8.5/tk.tcl: version conflict for package “Tk”: have
8.5.10, need exactly 8.5.11
version conflict for package “Tk”: have 8.5.10, need exactly 8.5.11
while executing
“package require -exact Tk 8.5.11”
(file “/usr/share/tcltk/tk8.5/tk.tcl” line 18)
invoked from within
“source /usr/share/tcltk/tk8.5/tk.tcl”
(“uplevel” body line 1)
invoked from within
“uplevel #0 [list source $file]”

Maybe, it is an install trouble on your Tcl/Tk.
Does wish8.5 run properly? If not, please ask it at Ubuntu community.
Else, do you have multi-versions of libtk8.5.so on your machine?
If so, please check dependency of the old version of Tcl/Tk library
and remove (should test by rename, first) the old one.

From: Bharadwaj S. [email protected]
Subject: Re: problem installing TkRuby on ubuntu 12.04
Date: Fri, 18 May 2012 03:19:15 +0900
Message-ID: [email protected]

=> true
Tk::TK_PATCHLEVEL
=> “8.5.11”

But the same installation with ruby1.9.1 instead shows me the errors in
OP instead when I require ‘tk’… and that is the problem.

Hmmm… Well, it may be a bug on “ext/tk/extconf.rb”.
Could you tell me the result of “ldd
(your_ruby191_lib_dir)/tcltklib.so”?

BTW, is it possible to GUI program in ruby1.9.1 using tk8.5 on ubuntu?

It should be possible.
Current Ruby/Tk cannot support Tcl/Tk8.6 (a new command of Tcl8.6 breaks
a call stack which includes Ruby’s method call), but must work with 8.5.

Could you rebuild libtcltk-ruby1.9.1 package with Tcl/Tk8.5.11
libraries?
And, if you can, send me “ext/tk/mkmf.log” and “ext/tk/Makefile”?
Probably, the rebuilded package will work properly.

Hidetoshi NAGAI wrote in post #1061251:

Hmmm… Well, it may be a bug on “ext/tk/extconf.rb”.
Could you tell me the result of “ldd
(your_ruby191_lib_dir)/tcltklib.so”?

I think my ruby1.9.1 library is at /usr/lib/ruby/1.9.1/x86_64linux
(correct me if I am wrong here)

This was the result when I used ldd:

linux-vdso.so.1 => (0x00007fff4746d000)
libruby-1.9.1.so.1.9 => /usr/lib/libruby-1.9.1.so.1.9
(0x00007f10edb99000)
libtcl8.5.so.0 => /usr/lib/libtcl8.5.so.0 (0x00007f10ed880000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f10ed585000)
libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6
(0x00007f10ed251000)
libXss.so.1 => /usr/lib/x86_64-linux-gnu/libXss.so.1
(0x00007f10ed04d000)
libXft.so.2 => /usr/lib/x86_64-linux-gnu/libXft.so.2
(0x00007f10ece37000)
libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1
(0x00007f10ecc01000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f10ec844000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0
(0x00007f10ec626000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f10ec41e000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f10ec21a000)
libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1
(0x00007f10ebfe0000)
/lib64/ld-linux-x86-64.so.2 (0x00007f10ee338000)
libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1
(0x00007f10ebdc2000)
libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6
(0x00007f10ebbb1000)
libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6
(0x00007f10eb914000)
libXrender.so.1 => /usr/lib/x86_64-linux-gnu/libXrender.so.1
(0x00007f10eb70a000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1
(0x00007f10eb4e0000)
libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6
(0x00007f10eb2dc000)
libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6
(0x00007f10eb0d6000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f10eaebe000)

It should be possible.
Current Ruby/Tk cannot support Tcl/Tk8.6 (a new command of Tcl8.6 breaks
a call stack which includes Ruby’s method call), but must work with 8.5.

Oh… that sounds interesting… Just asking out of curiosity, What is
that new command and How does it end up breaking the call stack? I tried
looking at your homepage, but it was in Japanese and I didn’t understand
it.

Could you rebuild libtcltk-ruby1.9.1 package with Tcl/Tk8.5.11
libraries?

I am newbie to building packages, but tried doing getting ruby1.9.1
source and compiling and installing it… but I think that is
essentially the same as getting it from apt-get.

TBH, I don’t know how to rebuild the package libtcltk-ruby1.9.1 with
Tcl/Tk8.5.11. If you can tell me how to do that, I will be able to do
it.

And, if you can, send me “ext/tk/mkmf.log” and “ext/tk/Makefile”?
Probably, the rebuilded package will work properly.

I am attaching those files. Those are just the files I am directly
attaching from source. I don’t know whether they belong to Tcl/Tk8.5.11
or not.

Hi,

I’m very sorry for my late reply.

From: Bharadwaj S. [email protected]
Subject: Re: problem installing TkRuby on ubuntu 12.04
Date: Fri, 18 May 2012 19:48:05 +0900
Message-ID: [email protected]

I think my ruby1.9.1 library is at /usr/lib/ruby/1.9.1/x86_64linux
(correct me if I am wrong here)

The reason of the trouble is that a Tk library (Tk 8.5.10) is
static-linked to tcltklib.so. Probably, it’s a bug on ext/tk/extconf.rb.
Please give me some time to fix it.

It should be possible.
Current Ruby/Tk cannot support Tcl/Tk8.6 (a new command of Tcl8.6 breaks
a call stack which includes Ruby’s method call), but must work with 8.5.

Oh… that sounds interesting… Just asking out of curiosity, What is
that new command and How does it end up breaking the call stack? I tried

It’s “tailcall” command.
“break” may not be a proper word. Probably, the command doesn’t expect
that it is called from a non-tcl function. So, a ruby function which
calls
a tcl function including tailcall gets an improper result.

Hidetoshi NAGAI wrote in post #1061752:

Hi,

I’m very sorry for my late reply.

Oh… No problem, I understand. :slight_smile:

The reason of the trouble is that a Tk library (Tk 8.5.10) is
static-linked to tcltklib.so. Probably, it’s a bug on ext/tk/extconf.rb.
Please give me some time to fix it.

Hmm… please reply me whenever you solve the problem. It’s been
sometime since you made this post… probably you might have solved it
already/ filed a bug I guess…

It’s “tailcall” command.
“break” may not be a proper word. Probably, the command doesn’t expect
that it is called from a non-tcl function. So, a ruby function which
calls a tcl function including tailcall gets an improper result.

Thanks for telling that!

I have asked the same question on AskUbuntu(long ago) - where I got this
answer recently in which I was asked to change a line in tcl.tk file in
/usr/share/tcltk/tk8.5

The 18th line “package require -exact Tk 8.5.11” when changed to
“package require -exact Tk 8.5.10” solves the problem and makes the
installation work (I haven’t experimented with it yet, but as of now the
require ‘tk’ works).

It seems like Tk 8.5.11 is not used (something like that) when I change
this line… but, I am not sure about what problems/ disadvantages I
might have if I go with this installation. But temporarily it works if I
do this change.

I am posting this for those who have the same problem and want to make
Tk work with ruby1.9.1 on ubuntu. I don’t think this post would be that
helpful for those trying to resolve the bug.

Hidetoshi NAGAI wrote in post #1061107:

Maybe, it is an install trouble on your Tcl/Tk.
Does wish8.5 run properly? If not, please ask it at Ubuntu community.
Else, do you have multi-versions of libtk8.5.so on your machine?
If so, please check dependency of the old version of Tcl/Tk library
and remove (should test by rename, first) the old one.

The installation process was ruby1.9.1 && tcl8.5 && tk8.5 &&
libtcltk-ruby1.9.1 one after the other, but when I require ‘tk’ in irb,
same error messages come up.

But, when I removed all those ruby1.9.1 packages and installed
ruby1.8-full (which includes libtcltk-ruby1.8), it works!

This is what irb shows when I have tcl8.5, rk8.5 with ruby1.8-full :

require ‘tk’
=> true
Tk::TK_PATCHLEVEL
=> “8.5.11”

But the same installation with ruby1.9.1 - shows me the errors in the OP
instead - when I require ‘tk’… and that is the problem I have.

BTW, is it possible to GUI program in ruby1.9.1 using tk8.5 on ubuntu?
If someone did it, please tell me. Even though it works in ruby1.8.7, I
want to shift to ruby1.9.1.


BTW, when I installed ruby1.9.1 it shows us ruby --version 1.9.3p0
because, I think ruby1.9.1 packages in ubuntu ship with latest ruby
interpreter that is 1.9.3 as given here:
https://launchpad.net/ubuntu/+source/ruby1.9.1/1.9.3.0-1

(I was initially confused when I saw this… correct me if I am wrong
somewhere.)