Tk not working after Debian upgrade to 10

I made a successful manual upgrade from Debian 9 to Debian 10.
On 9, I used Ruby2.3 with ruby2.3-tcltk.
On 10, Ruby is 2.5.5 and surprise! Tk didn’t work!

I have tried
sudo gem update
sudo gem install tk

The latter failed:

ERROR: Error installing tk:
ERROR: Failed to build gem native extension.

current directory: /var/lib/gems/2.5.0/gems/tk-0.2.0/ext/tk

and complains among many other things

Search tcl.h
checking for tcl.h… no
Search tk.h
checking for tk.h… no
Search Tcl library…*** extconf.rb failed ***

Among other things, mkmf.log confirmed that it was missing these .h files.

I found a Rubytk_patch.rb to get tk to work for versions of
Ruby later than 2.4 and executed that with much the same result.

Will wiping my computer, installing Debian 10 from scratch plus
running Rubytk_patch.rb magically make Tk work? Somehow, I have
my doubts.

I am not impressed with the Tk problems every time I upgrade Ruby.
My many Perl and Python tk-programs work perfectly well from one version to the next.

I really like Ruby and Tk has become reasonably fast after Ruby2.3.

Yeah there’s a screw up with it. They took it out of the compiler in 2.4. It took me a long ass time to find the fix and I made a patch script so folks like yourself won’t have to deal with what I had to get it working again. It’s on my GitHub here:

It installs the ruby-full-dev and then the to gem with the tcl2.6 bindings. Afterwards it makes a test window via rubytk so you can see that it’s working.


I didn’t realize that you found my patch already. It didn’t work for you? I tested it on 3 distros before uploading it… However I already did the symlink beforehand. I wonder if I added that I to the patch if it would correct it.


I updated the patch to include the softlinks. Give it another try and let me know of your results.

Thanks for the fast reply! Alas, same result :frowning:
Since you are an expert, I will show the whole set of errors as it may make sense to you.

rb Rubytk_patch.rb
2019-05-28 07:18:15 +0200
Installing Ruby-All-dev
[sudo] password for jorgen:
creating softlinks
Installing TK GEM with TCL8.6-dev
ERROR: Error installing tk:
ERROR: Failed to build gem native extension.

current directory: /var/lib/gems/2.5.0/gems/tk-0.2.0/ext/tk

/usr/bin/ruby2.5 -I /usr/local/lib/site_ruby/2.5.0 -r ./siteconf20190528-2317-4d8buh.rb extconf.rb --with-tcltkversion=8.6 --with-tcl-lib=/usr/lib/x86_64-linux-gnu --with-tk-lib=/usr/lib/x86_64-linux-gnu --with-tcl-include=/usr/include/tcl8.6 --with-tk-include=/usr/include/tcl8.6 --enable-pthread
Configure options for Ruby/Tk may be updated.
So, delete files which depend on old configs.
check functions.checking for ruby_native_thread_p() in ruby.h… yes
checking for rb_errinfo() in ruby.h… yes
checking for rb_safe_level() in ruby.h… yes
checking for rb_hash_lookup() in ruby.h… yes
checking for rb_proc_new() in ruby.h… yes
checking for rb_obj_untrust() in ruby.h… yes
checking for rb_obj_taint() in ruby.h… yes
checking for rb_set_safe_level_force() in ruby.h… yes
checking for rb_sourcefile() in ruby.h… yes
checking for rb_thread_alive_p() in ruby.h… no
checking for rb_thread_check_trap_pending() in ruby.h… yes
checking for ruby_enc_find_basename() in ruby.h… yes
check libraries.checking for t_open() in -lnsl… no
checking for socket() in -lsocket… no
checking for dlopen() in -ldl… yes
checking for log() in -lm… yes
Specified Tcl/Tk version is [“8.6”, “8.6”]
Use ActiveTcl libraries (if available).
Search tclConfig.sh (in /usr/lib/x86_64-linux-gnu) and tkConfig.sh (in /usr/lib/x86_64-linux-gnu).
Fail to find [tclConfig.sh, tkConfig.sh]
Use X11 libraries (or use TK_XINCLUDES/TK_XLIBSW information on tkConfig.sh).
checking for XOpenDisplay() in -lX11… yes
Search tcl.h
checking for tcl.h… no
Search tk.h
checking for tk.h… no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.

Provided configuration options:
–with-opt-dir
–without-opt-dir
–with-opt-include
–without-opt-include=${opt-dir}/include
–with-opt-lib
–without-opt-lib=${opt-dir}/lib
–with-make-prog
–without-make-prog
–srcdir=.
–curdir
–ruby=/usr/bin/$(RUBY_BASE_NAME)2.5
–enable-shared
–with-tk-old-extconf
–without-tk-old-extconf
–with-tk-old-extconf
–without-tk-old-extconf
–with-ActiveTcl
–without-ActiveTcl
–with-tk-shlib-search-path
–without-tk-shlib-search-path
–with-tcltkversion
–with-tcl-build-dir
–without-tcl-build-dir
–with-tk-build-dir
–without-tk-build-dir
–with-tcl-config
–without-tcl-config
–with-tk-config
–without-tk-config
–with-tclConfig-dir
–without-tclConfig-dir
–with-tkConfig-dir
–without-tkConfig-dir
–with-tclConfig-file
–without-tclConfig-file
–with-tkConfig-file
–without-tkConfig-file
–with-tcllib
–without-tcllib
–with-tklib
–without-tklib
–with-tcl-dir
–without-tcl-dir
–with-tk-dir
–without-tk-dir
–with-tcl-include
–with-tk-include
–with-tcl-lib
–with-tk-lib
–with-tcltk-framework
–without-tcltk-framework
–with-tcl-framework-dir
–without-tcl-framework-dir
–with-tk-framework-dir
–without-tk-framework-dir
–with-tcl-framework-header
–without-tcl-framework-header
–with-tk-framework-header
–without-tk-framework-header
–with-X11
–without-X11
–with-X11-dir
–without-X11-dir
–with-X11-include
–without-X11-include
–with-X11-lib
–without-X11-lib
–enable-tcltk-stubs
–disable-tcltk-stubs
–enable-tcl-h-ver-check
–disable-tcl-h-ver-check
–enable-tk-h-ver-check
–disable-tk-h-ver-check
–enable-mac-tcltk-framework
–disable-mac-tcltk-framework
–enable-tcltk-framework
–disable-tcltk-framework
–enable-pthread
–enable-tcl-thread
–disable-tcl-thread
–enable-space-on-tk-libpath
–disable-space-on-tk-libpath
–with-nsllib
–without-nsllib
–with-socketlib
–without-socketlib
–with-dllib
–without-dllib
–with-mlib
–without-mlib
–with-tcl-build-dir
–without-tcl-build-dir
–with-tk-build-dir
–without-tk-build-dir
–with-tcltkversion
–with-ActiveTcl
–without-ActiveTcl
–enable-space-on-tk-libpath
–disable-space-on-tk-libpath
–enable-tcltk-stubs
–disable-tcltk-stubs
–with-tcltk-stubs
–without-tcltk-stubs
–with-tcl-dir
–without-tcl-dir
–with-tcl-include=${tcl-dir}/include
–with-tcl-lib=${tcl-dir}/lib
–with-tk-dir
–without-tk-dir
–with-tk-include=${tk-dir}/include
–with-tk-lib=${tk-dir}/lib
–with-tclConfig-file
–without-tclConfig-file
–with-tkConfig-file
–without-tkConfig-file
–with-tclConfig-dir
–without-tclConfig-dir
–with-tkConfig-dir
–without-tkConfig-dir
–with-tk-shlib-search-path
–without-tk-shlib-search-path
–with-tklib
–without-tklib
–with-tcllib
–without-tcllib
–with-X11
–without-X11
–with-X11-dir
–without-X11-dir
–with-X11-include
–without-X11-include=${X11-dir}/include
–with-X11-lib
–without-X11-lib=${X11-dir}/lib
–with-X11-lib
–without-X11-lib
–with-X11lib
–without-X11lib
–enable-tcl-h-ver-check
–disable-tcl-h-ver-check
–enable-tk-h-ver-check
–disable-tk-h-ver-check
Can’t find “tcl.h”.
Can’t find “tk.h”.

Can’t find proper Tcl/Tk libraries. So, can’t make tcltklib.so which is required by Ruby/Tk.
If you have Tcl/Tk libraries on your environment, you may be able to use them with configure options (see ext/tk/README.tcltklib).
At present, Tcl/Tk8.6 is not supported. Although you can try to use Tcl/Tk8.6 with configure options, it will not work correctly. I recommend you to use Tcl/Tk8.5 or 8.4.

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/tk-0.2.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.5.0/gems/tk-0.2.0 for inspection.
Results logged to /var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/tk-0.2.0/gem_make.out
testing TK GEM
2019-05-28 07:18:31 +0200
Traceback (most recent call last):
3: from Rubytk_patch.rb:17:in <main>' 2: from Rubytk_patch.rb:42:inclass:TK_Patch
1: from /usr/local/lib/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in require' /usr/local/lib/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:inrequire’: cannot load such file – tk (LoadError)

I wonder… Try installing tcl8.6 then try the patch.

Try
sudo apt-get install tcl8.6-dev tk8.6-dev

If this works I’ll modify the patch to include this command

This time it got tcl.h but is still missing tk.h

2019-05-28 08:50:01 +0200
Installing Ruby-All-dev
creating softlinks
ln: failed to create symbolic link ‘/usr/lib/tclConfig.sh’: File exists
ln: failed to create symbolic link ‘/usr/lib/tkConfig.sh’: File exists
ln: failed to create symbolic link ‘/usr/lib/libtcl8.5.so.0’: File exists
ln: failed to create symbolic link ‘/usr/lib/libtk8.5.so.0’: File exists
Installing TK GEM with TCL8.6-dev
ERROR: Error installing tk:
ERROR: Failed to build gem native extension.

current directory: /var/lib/gems/2.5.0/gems/tk-0.2.0/ext/tk

/usr/bin/ruby2.5 -I /usr/local/lib/site_ruby/2.5.0 -r ./siteconf20190528-3397-1st31vx.rb extconf.rb --with-tcltkversion=8.6 --with-tcl-lib=/usr/lib/x86_64-linux-gnu --with-tk-lib=/usr/lib/x86_64-linux-gnu --with-tcl-include=/usr/include/tcl8.6 --with-tk-include=/usr/include/tcl8.6 --enable-pthread
Configure options for Ruby/Tk may be updated.
So, delete files which depend on old configs.
check functions.checking for ruby_native_thread_p() in ruby.h… yes
checking for rb_errinfo() in ruby.h… yes
checking for rb_safe_level() in ruby.h… yes
checking for rb_hash_lookup() in ruby.h… yes
checking for rb_proc_new() in ruby.h… yes
checking for rb_obj_untrust() in ruby.h… yes
checking for rb_obj_taint() in ruby.h… yes
checking for rb_set_safe_level_force() in ruby.h… yes
checking for rb_sourcefile() in ruby.h… yes
checking for rb_thread_alive_p() in ruby.h… no
checking for rb_thread_check_trap_pending() in ruby.h… yes
checking for ruby_enc_find_basename() in ruby.h… yes
check libraries.checking for t_open() in -lnsl… no
checking for socket() in -lsocket… no
checking for dlopen() in -ldl… yes
checking for log() in -lm… yes
Specified Tcl/Tk version is [“8.6”, “8.6”]
Use ActiveTcl libraries (if available).
Search tclConfig.sh (in /usr/lib/x86_64-linux-gnu) and tkConfig.sh (in /usr/lib/x86_64-linux-gnu).
Fail to find [tclConfig.sh, tkConfig.sh]
Use X11 libraries (or use TK_XINCLUDES/TK_XLIBSW information on tkConfig.sh).
checking for XOpenDisplay() in -lX11… yes
Search tcl.h
checking for tcl.h… yes
Search tk.h
checking for tk.h… no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.

Provided configuration options:
–with-opt-dir
–without-opt-dir
–with-opt-include
–without-opt-include=${opt-dir}/include
–with-opt-lib
–without-opt-lib=${opt-dir}/lib
–with-make-prog
–without-make-prog
–srcdir=.
–curdir
–ruby=/usr/bin/$(RUBY_BASE_NAME)2.5
–enable-shared
–with-tk-old-extconf
–without-tk-old-extconf
–with-tk-old-extconf
–without-tk-old-extconf
–with-ActiveTcl
–without-ActiveTcl
–with-tk-shlib-search-path
–without-tk-shlib-search-path
–with-tcltkversion
–with-tcl-build-dir
–without-tcl-build-dir
–with-tk-build-dir
–without-tk-build-dir
–with-tcl-config
–without-tcl-config
–with-tk-config
–without-tk-config
–with-tclConfig-dir
–without-tclConfig-dir
–with-tkConfig-dir
–without-tkConfig-dir
–with-tclConfig-file
–without-tclConfig-file
–with-tkConfig-file
–without-tkConfig-file
–with-tcllib
–without-tcllib
–with-tklib
–without-tklib
–with-tcl-dir
–without-tcl-dir
–with-tk-dir
–without-tk-dir
–with-tcl-include
–with-tk-include
–with-tcl-lib
–with-tk-lib
–with-tcltk-framework
–without-tcltk-framework
–with-tcl-framework-dir
–without-tcl-framework-dir
–with-tk-framework-dir
–without-tk-framework-dir
–with-tcl-framework-header
–without-tcl-framework-header
–with-tk-framework-header
–without-tk-framework-header
–with-X11
–without-X11
–with-X11-dir
–without-X11-dir
–with-X11-include
–without-X11-include
–with-X11-lib
–without-X11-lib
–enable-tcltk-stubs
–disable-tcltk-stubs
–enable-tcl-h-ver-check
–disable-tcl-h-ver-check
–enable-tk-h-ver-check
–disable-tk-h-ver-check
–enable-mac-tcltk-framework
–disable-mac-tcltk-framework
–enable-tcltk-framework
–disable-tcltk-framework
–enable-pthread
–enable-tcl-thread
–disable-tcl-thread
–enable-space-on-tk-libpath
–disable-space-on-tk-libpath
–with-nsllib
–without-nsllib
–with-socketlib
–without-socketlib
–with-dllib
–without-dllib
–with-mlib
–without-mlib
–with-tcl-build-dir
–without-tcl-build-dir
–with-tk-build-dir
–without-tk-build-dir
–with-tcltkversion
–with-ActiveTcl
–without-ActiveTcl
–enable-space-on-tk-libpath
–disable-space-on-tk-libpath
–enable-tcltk-stubs
–disable-tcltk-stubs
–with-tcltk-stubs
–without-tcltk-stubs
–with-tcl-dir
–without-tcl-dir
–with-tcl-include=${tcl-dir}/include
–with-tcl-lib=${tcl-dir}/lib
–with-tk-dir
–without-tk-dir
–with-tk-include=${tk-dir}/include
–with-tk-lib=${tk-dir}/lib
–with-tclConfig-file
–without-tclConfig-file
–with-tkConfig-file
–without-tkConfig-file
–with-tclConfig-dir
–without-tclConfig-dir
–with-tkConfig-dir
–without-tkConfig-dir
–with-tk-shlib-search-path
–without-tk-shlib-search-path
–with-tklib
–without-tklib
–with-tcllib
–without-tcllib
–with-X11
–without-X11
–with-X11-dir
–without-X11-dir
–with-X11-include
–without-X11-include=${X11-dir}/include
–with-X11-lib
–without-X11-lib=${X11-dir}/lib
–with-X11-lib
–without-X11-lib
–with-X11lib
–without-X11lib
–enable-tcl-h-ver-check
–disable-tcl-h-ver-check
–enable-tk-h-ver-check
–disable-tk-h-ver-check
Can’t find “tk.h”.

Can’t find proper Tcl/Tk libraries. So, can’t make tcltklib.so which is required by Ruby/Tk.
If you have Tcl/Tk libraries on your environment, you may be able to use them with configure options (see ext/tk/README.tcltklib).
At present, Tcl/Tk8.6 is not supported. Although you can try to use Tcl/Tk8.6 with configure options, it will not work correctly. I recommend you to use Tcl/Tk8.5 or 8.4.

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/tk-0.2.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.5.0/gems/tk-0.2.0 for inspection.
Results logged to /var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/tk-0.2.0/gem_make.out
testing TK GEM
2019-05-28 08:50:11 +0200
Traceback (most recent call last):
3: from Rubytk_patch.rb:17:in <main>' 2: from Rubytk_patch.rb:42:inclass:TK_Patch
1: from /usr/local/lib/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in require' /usr/local/lib/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:inrequire’: cannot load such file – tk (LoadError)

Sorry it was late and I fell asleep. I’m not giving up in this. I got my coffee and I’m at my laptop. Let me do some research and I’ll get back to you. We shall solve this mystery together!

1 Like

Okay
sudo apt-get install tcl8.6-dev(check)
sudo apt-get install tk8.6-dev(try this next)
If that doesn’t work use
sudo apt-get install libtk8.6

I knowticed a goof on my part because I was tired. I’ll fix it in the patch on GitHub. The simbolic links are for 8.5 not 8.6

You can reclone the updated fix or you can open your current script and make the changes yourself. Lines 24-27 are the commands. If you open the file in a text Editor edit the 8.5 to 8.6 on these lines.15590633303301938313068|375x500

1 Like

You are a genius!
I needed tk86… Now all my Tk programs are running happily!

Thank you so much for this!

Glad to help! And thanks for letting me know the bugs in my patch!

1 Like