tk icon indicating copy to clipboard operation
tk copied to clipboard

Support for Tcl/Tk 8.7

Open codebykevin opened this issue 2 years ago • 8 comments

I am a member of the core Tcl/Tk development team and have wanting to test Ruby-Tk against some recent updates to the tip of Tk 8.7 in a Ruby app I maintain. I'm unable to build this gem against Tk 8.7 because it is listed as an unsupported version in extconf.rb. I have tried manually editing the file and also passing 8.7 as a configure flag ("--with-tcltkversion=8.7") but the build system seems to ignore these flags and/or overwrite my locally edited configuration. Can you either add support for Tcl/Tk 8.7 or provide guidance on how to override the restrictions in this gem? I understand that Tk 8.7 is not yet released, but it is maturing rapidly and it would be helpful to be able to build this gem against that version. Thank you.

codebykevin avatar Oct 14 '21 12:10 codebykevin

Interestingly, passing these configure flags:

gem install tk -- --with-tcltkversion=8.7 --with-tcllib=tcl87 --with-tklib=tk87 --with-tk-shlib-search-path=C:/Ruby30-x64/msys64/usr ---with-tcl-dir=C:/Ruby30-x64/msys64/usr --with-tk-dir=C:/Ruby30-x64/msys64/usr

appears to builds the gem successfully, but things still do not run:

irb(main):001:0> require 'tk'
<internal:C:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require': 126: The specified module could not be found.   - C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/tk-0.4.0/lib/tcltklib.so (LoadError)

tcltklib.so is indeed found in the directory, so the "could not be found" message is misleading. I wonder if it is a versioning issue - is more work required with Ruby-Tk's internals to support Tcl/Tk 8.7 than just doing a version bump?

codebykevin avatar Oct 14 '21 12:10 codebykevin

My setup is the current version of RubyInstaller (3.0), and Tcl/Tk tip-of-8.7 built against MinGW, on Windows 10.

codebykevin avatar Oct 14 '21 12:10 codebykevin

I don't think there are any current plans to support Tcl/Tk 8.7. However, we would definitely consider a pull request that added support for 8.7 without changing behavior for other supported versions.

I searched for that error message in both the ruby and ruby-tk sources and couldn't find it. Is it an error message from Tcl/Tk that Ruby is using when raising the exception?

Your best bet for debugging this is build ruby and the gem with debugging symbols, then run ruby using a debugger to see exactly where that exception is being raised. You could probably put breakpoints on rb_raise and rb_exc_raise, then get a C-level backtrace from there. You'll want to keep getting such backtraces until the program exits, then the last backtrace should be the one related to the problem.

jeremyevans avatar Oct 14 '21 15:10 jeremyevans

That's a Ruby error message--a Google search for the string shows up several Stack Overflow entries on various modules.

I suspect the issue is simply that, as you say, Tcl/Tk 8.7 isn't supported. Perhaps I'll come back when 8.7 is officially released.

codebykevin avatar Oct 14 '21 17:10 codebykevin

Leaving open to keep on the board and track with Tcl/Tk release.

codebykevin avatar Oct 31 '21 02:10 codebykevin

Today I just read this on ruby reddit:

https://old.reddit.com/r/ruby/comments/1169ti9/whatever_happened_to_ruby/

This part I found quite interesting:

"Apparently Ruby don’t support tk 8.6"

Now, personally, I use mostly ruby-gtk3, which works well for my use cases. But some people use ruby-tk, such as glimmer-tk such as Andy here:

https://github.com/AndyObtiva/glimmer-dsl-tk

So for these projects it would be nice if someone could find and track progress for ruby-tk in regards to tk 8.6, 8.7 or any other later version.

rubyFeedback avatar Feb 21 '23 16:02 rubyFeedback

I guess the question is how/if one can track progress for the ruby-specific parts, to allow for tk 8.6 and so forth.

I assume one would need some C knowledge? This would probably be where many people drop off. I know some ruby, but my C knowledge is very, very limited.

But what if we could, say, add partial support? So people could work on some widgets, and make these work (with tests) and then move on to do other things. That would still be better than no support for later tk.

rubyFeedback avatar Feb 21 '23 16:02 rubyFeedback

@rubyFeedback Ruby most certainly supports Tk 8.6. That is the main version that was used in Glimmer DSL for Tk (note how it mentions ActiveTcl 8.6).

Everybody makes mistakes and people say things that are wrong sometimes. Don't take their word for granted no matter how many people agree with them as everyone could be wrong every once in a while. Always question everything and investigate facts yourself.

AndyObtiva avatar Feb 21 '23 16:02 AndyObtiva