Need Ruby 2.5 and TK connection

#1

I had Ruby 2.2 and 2.3 installed that contained TK. I installed Ruby 2.5 that does not come with TK. I installed ActiveTCL 8.6 with the idea that I can use it with Ruby 2.5. I tried “gem install tk” which did not work. Can I bind Ruby 2.5 and ActiveTCL 8.6 together? If, so, how?

#2

Firstly, what is your OS?
And secondly, while running gem install tk are you getting any errors? If yes, please run the command gem install tk again, and paste in the error here…

#3

Thank you for your reply. Am running on Window 7 - sorry that I forgot to include that.
Another oops: gem install tk works. I get this error when I run a simple app:
:\Users\Owner\Home\RubyHome>ruby hello.rb
raceback (most recent call last):
6: from hello.rb:2:in <main>' 5: from C:/Ruby25-x64/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:39:inrequire’
4: from C:/Ruby25-x64/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in rescue in require' 3: from C:/Ruby25-x64/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:inrequire’
2: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/tk-0.2.0/lib/tk.rb:7:in <top (required)>' 1: from C:/Ruby25-x64/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:inrequire’
:/Ruby25-x64/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require’: 126: The specified module could not be found. - C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/tk-0.2.0/lib/tcltklib.so (LoadError)

Code:
#!/bin/ruby
require ‘tk’; #This does not work with Ruby 2.5

where = where ruby; where = “where ruby:\n” + where;
ver = ruby -v; ver = ver[0…9];
path = ENV[‘PATH’]; path = path[0…52];

msg = 'Hello from Ruby ’ + RUBY_VERSION + ’ -OR- ’ + ver;
print(where + “\n” + "PATH " + path + “\n” + msg + “\n”);

root = TkRoot.new {title “Hello, World!”};
TkLabel.new(root) do text msg; pack {padx 15; pady 15; side ‘left’}; end
Tk.mainloop;

#4

I made a patch for this. However if you’re using Linux mint it won’t take yet. Any other Deb Linux like Ubuntu it will work however.

I did a update of it but haven’t had a chance to to put it on GitHub. Give me about an hour and I’ll have the new patch up.

#5

With Windows… The patch won’t work. However in 2.4 tk was taken out and made a gem. So you will have to install the tk gem to your interpreter.