Skip to content

How to make it work with TkRuby? #10

@krepkiy

Description

@krepkiy

Hello. It doesn't work for me with TkRuby.
Maybe someone knows how to make it work?

ruby 3.2.3 (2024-01-18 revision 52bb2ac0a6) [x64-mingw-ucrt]
tk (0.5.0)
ocran (1.3.15)

My file test_tk.rb
require 'tk' root = TkRoot.new { title "Ex1" } TkLabel.new(root) { text 'Hello, World!' pack { padx 55 ; pady 55; side 'left' } } Tk.mainloop

option 1
# ocran test_tk.rb --windows === Loading script to check dependencies === Attempting to trigger autoload of #<Class:Tk>::WinRegistry === Attempting to trigger autoload of #<Class:Tk>::ValidateConfigure === Attempting to trigger autoload of #<Class:Tk>::BinaryString === Attempting to trigger autoload of #<Class:Tk>::AUTO_PATH === Attempting to trigger autoload of #<Class:Tk>::Tile C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/tk-0.5.0/lib/tk.rb:2887:in _invoke': can't invoke "font" command: application has been destroyed (RuntimeError)
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/tk-0.5.0/lib/tk.rb:2887:in _invoke' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/tk-0.5.0/lib/tk.rb:1932:in _ip_invoke_core'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/tk-0.5.0/lib/tk.rb:1965:in _tk_call_core' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/tk-0.5.0/lib/tk.rb:1988:in tk_call'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/tk-0.5.0/lib/tk/font.rb:126:in <class:TkFont>' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/tk-0.5.0/lib/tk/font.rb:9:in <top (required)>'
from internal:C:/Ruby32-x64/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb:86:in require' from <internal:C:/Ruby32-x64/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in require'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/tk-0.5.0/lib/tkextlib/tile.rb:293:in <module:Font>' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/tk-0.5.0/lib/tkextlib/tile.rb:281:in module:Tile'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/tk-0.5.0/lib/tkextlib/tile.rb:113:in <module:Tk>' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/tk-0.5.0/lib/tkextlib/tile.rb:112:in <top (required)>'
from internal:C:/Ruby32-x64/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb:86:in require' from <internal:C:/Ruby32-x64/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in require'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/ocran-1.3.15/bin/ocran:518:in const_get' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/ocran-1.3.15/bin/ocran:518:in block (3 levels) in attempt_load_autoload'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/ocran-1.3.15/bin/ocran:514:in each' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/ocran-1.3.15/bin/ocran:514:in block (2 levels) in attempt_load_autoload'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/ocran-1.3.15/bin/ocran:512:in each' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/ocran-1.3.15/bin/ocran:512:in block in attempt_load_autoload'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/ocran-1.3.15/bin/ocran:506:in loop' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/ocran-1.3.15/bin/ocran:506:in attempt_load_autoload'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/ocran-1.3.15/bin/ocran:774:in build_exe' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/ocran-1.3.15/bin/ocran:1307:in block in <top (required)>'`

option 2 (compiled done but not executed)
`# ocran test_tk.rb --windows --no-autoload
=== Loading script to check dependencies
=== Using default specification C:/Ruby32-x64/lib/ruby/gems/3.2.0/specifications/default/error_highlight-0.5.1.gemspec for gem error_highlight-0.5.1
=== Detected gem error_highlight-0.5.1 (loaded, files)
=== 0 files, 0 bytes
=== Using default specification C:/Ruby32-x64/lib/ruby/gems/3.2.0/specifications/default/did_you_mean-1.6.3.gemspec for gem did_you_mean-1.6.3
=== Detected gem did_you_mean-1.6.3 (loaded, files)
=== 0 files, 0 bytes
=== Using default specification C:/Ruby32-x64/lib/ruby/gems/3.2.0/specifications/default/syntax_suggest-1.1.0.gemspec for gem syntax_suggest-1.1.0
=== Detected gem syntax_suggest-1.1.0 (loaded, files)
=== 1 files, 111 bytes
=== Detected gem ocran-1.3.15 (loaded, files)
=== 6 files, 284024 bytes
=== Detected gem tk-0.5.0 (loaded, files)
=== 415 files, 2939900 bytes
=== Including 61 encoding support files (3775488 bytes, use --no-enc to exclude)
=== Building test_tk.exe
=== Adding user-supplied source files
=== Adding ruby executable rubyw.exe
=== Adding detected DLL C:/Ruby32-x64/bin/ruby_builtin_dlls/libgmp-10.dll
=== Adding detected DLL C:/Ruby32-x64/msys64/ucrt64/bin/tk86.dll
=== Adding detected DLL C:/Ruby32-x64/msys64/ucrt64/bin/tcl86.dll
=== Adding detected DLL C:/Ruby32-x64/bin/ruby_builtin_dlls/zlib1.dll
=== Adding detected DLL C:/Ruby32-x64/bin/ruby_builtin_dlls/libffi-8.dll
=== Adding external manifest C:/Ruby32-x64/bin/ruby_builtin_dlls/ruby_builtin_dlls.manifest
=== Adding library files
=== Compressing 16729037 bytes

LZMA 22.01 (x86) : Igor Pavlov : Public domain : 2022-07-15

Input size: 16729037 (15 MiB)
Output size: 4445085 (4 MiB)
=== Finished building test_tk.exe (4492721 bytes)`

option 3
# ocran test_tk.rb --windows --no-autoload --debug === Loading script to check dependencies === Using default specification C:/Ruby32-x64/lib/ruby/gems/3.2.0/specifications/default/error_highlight-0.5.1.gemspec for gem error_highlight-0.5.1 === Detected gem error_highlight-0.5.1 (loaded, files) === 0 files, 0 bytes === Using default specification C:/Ruby32-x64/lib/ruby/gems/3.2.0/specifications/default/did_you_mean-1.6.3.gemspec for gem did_you_mean-1.6.3 === Detected gem did_you_mean-1.6.3 (loaded, files) === 0 files, 0 bytes === Using default specification C:/Ruby32-x64/lib/ruby/gems/3.2.0/specifications/default/syntax_suggest-1.1.0.gemspec for gem syntax_suggest-1.1.0 === Detected gem syntax_suggest-1.1.0 (loaded, files) === 1 files, 111 bytes === Detected gem ocran-1.3.15 (loaded, files) === 6 files, 284024 bytes === Detected gem tk-0.5.0 (loaded, files) === 415 files, 2939900 bytes === Including 61 encoding support files (3775488 bytes, use --no-enc to exclude) C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/ocran-1.3.15/bin/ocran:84:in +': no implicit conversion of nil into String (TypeError)

  @path = sub(/(\.[^.]*?|)$/) { s.to_s + $1 }
                                         ^^
    from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/ocran-1.3.15/bin/ocran:84:in `block in append_to_filename!'
    from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/ocran-1.3.15/bin/ocran:88:in `sub'
    from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/ocran-1.3.15/bin/ocran:88:in `sub'
    from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/ocran-1.3.15/bin/ocran:84:in `append_to_filename!'
    from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/ocran-1.3.15/bin/ocran:921:in `build_exe'
    from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/ocran-1.3.15/bin/ocran:1307:in `block in <top (required)>'`

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions