Forum: Ruby Problems with using Ocra.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
1474c56f7078a0bfddbf16b129d2f935?d=identicon&s=25 Anton Kiyan (antibreez)
on 2016-11-19 20:48
I try to create EXE file by Ocra. I have Tk in my script:

-----------------------------------------------------------------------
require 'tk'
require 'tkextlib/tile'

root = TkRoot.new {title "Feet to Meters"}
content = Tk::Tile::Frame.new(root) {padding "3 3 12 12"}.grid( :sticky
=> 'nsew')
TkGrid.columnconfigure root, 0, :weight => 1; TkGrid.rowconfigure root,
0, :weight => 1

$feet = TkVariable.new; $meters = TkVariable.new
f = Tk::Tile::Entry.new(content) {width 7; textvariable $feet}.grid(
:column => 2, :row => 1, :sticky => 'we' )
Tk::Tile::Label.new(content) {textvariable $meters}.grid( :column => 2,
:row => 2, :sticky => 'we');
Tk::Tile::Button.new(content) {text 'Calculate'; command
{calculate}}.grid( :column => 3, :row => 3, :sticky => 'w')

Tk::Tile::Label.new(content) {text 'feet'}.grid( :column => 3, :row =>
1, :sticky => 'w')
Tk::Tile::Label.new(content) {text 'is equivalent to'}.grid( :column =>
1, :row => 2, :sticky => 'e')
Tk::Tile::Label.new(content) {text 'meters'}.grid( :column => 3, :row =>
2, :sticky => 'w')

TkWinfo.children(content).each {|w| TkGrid.configure w, :padx => 5,
:pady => 5}
f.focus
root.bind("Return") {calculate}

def calculate
  begin
     $meters.value = (0.3048*$feet*10000.0).round()/10000.0
  rescue
     $meters.value = ''
  end
end

Tk.mainloop

-----------------------------------------------------------------------------And
that is what I've got in my console:
-----------------------------------------------------------------------------
C:\Users\Anton\Desktop\Programs>ocra test.rb
=== Loading script to check dependencies
=== Attempting to trigger autoload of
#<Class:#<Tk::Tile::TEntry:0x000000051bd438>>::Pack
=== WARNING: #<Class:#<Tk::Tile::TEntry:0x000000051bd438>>::Pack was
defined autoloadable, but caused NameError
=== Attempting to trigger autoload of
#<Class:#<Tk::Tile::TEntry:0x000000051bd438>>::Place
=== WARNING: #<Class:#<Tk::Tile::TEntry:0x000000051bd438>>::Place was
defined autoloadable, but caused NameError
=== Attempting to trigger autoload of
#<Class:#<Tk::Tile::TEntry:0x000000051bd438>>::Canvas
=== Attempting to trigger autoload of
#<Class:#<Tk::Tile::TEntry:0x000000051bd438>>::CheckButton
=== Attempting to trigger autoload of
#<Class:#<Tk::Tile::TEntry:0x000000051bd438>>::LabelFrame
=== Attempting to trigger autoload of
#<Class:#<Tk::Tile::TEntry:0x000000051bd438>>::Listbox
=== Attempting to trigger autoload of
#<Class:#<Tk::Tile::TEntry:0x000000051bd438>>::Menu
=== Attempting to trigger autoload of
#<Class:#<Tk::Tile::TEntry:0x000000051bd438>>::Message
=== Attempting to trigger autoload of
#<Class:#<Tk::Tile::TEntry:0x000000051bd438>>::PanedWindow
=== Attempting to trigger autoload of
#<Class:#<Tk::Tile::TEntry:0x000000051bd438>>::Scale
=== Attempting to trigger autoload of
#<Class:#<Tk::Tile::TEntry:0x000000051bd438>>::Scrollbar
=== Attempting to trigger autoload of
#<Class:#<Tk::Tile::TEntry:0x000000051bd438>>::Spinbox
=== Attempting to trigger autoload of
#<Class:#<Tk::Tile::TEntry:0x000000051bd438>>::Text
=== Attempting to trigger autoload of
#<Class:#<Tk::Tile::TEntry:0x000000051bd438>>::Toplevel
=== Attempting to trigger autoload of
#<Class:#<Tk::Tile::TEntry:0x000000051bd438>>::Clock
=== Attempting to trigger autoload of
#<Class:#<Tk::Tile::TEntry:0x000000051bd438>>::OptionObj
=== Attempting to trigger autoload of
#<Class:#<Tk::Tile::TEntry:0x000000051bd438>>::Fontchooser
=== Attempting to trigger autoload of
#<Class:#<Tk::Tile::TEntry:0x000000051bd438>>::MacResource
C:/Ruby23-x64/lib/ruby/2.3.0/tk/macpkg.rb:42:in `<module:MacResource>':
RuntimeError (RuntimeError)
        from C:/Ruby23-x64/lib/ruby/2.3.0/tk/macpkg.rb:31:in `<top
(required)>'
        from
C:/Ruby23-x64/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in
`require'
        from
C:/Ruby23-x64/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in
`require'
        from
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ocra-1.3.6/bin/ocra:477:in
`const_get'
        from
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ocra-1.3.6/bin/ocra:477:in `block
(3 levels) in attempt_load_autoload'
        from
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ocra-1.3.6/bin/ocra:471:in `each'
        from
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ocra-1.3.6/bin/ocra:471:in `block
(2 levels) in attempt_load_autoload'
        from
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ocra-1.3.6/bin/ocra:469:in `each'
        from
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ocra-1.3.6/bin/ocra:469:in `block
in attempt_load_autoload'
        from
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ocra-1.3.6/bin/ocra:463:in `loop'
        from
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ocra-1.3.6/bin/ocra:463:in
`attempt_load_autoload'
        from
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ocra-1.3.6/bin/ocra:715:in
`build_exe'
        from
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ocra-1.3.6/bin/ocra:1177:in
`block in <top (required)>'

--------------------------------------------------------------------------------

Can anyone please help me to solve this problem?
14b5582046b4e7b24ab69b7886a35868?d=identicon&s=25 Joel Pearson (virtuoso)
on 2016-11-20 12:47
Have a look at the switches you can use with Ocra. I had to try several
times before it worked and I don't have the code in front of me, but
this was the first suggestion I found when looking online:

ocra rubyfile.rb --windows C:\Ruby192\lib\tcltk\ --no-autoload
--add-all-core

Add in your own script & tk directory.
1474c56f7078a0bfddbf16b129d2f935?d=identicon&s=25 Anton Kiyan (antibreez)
on 2016-11-20 16:32
Joel Pearson wrote in post #1185262:
> Have a look at the switches you can use with Ocra. I had to try several
> times before it worked and I don't have the code in front of me, but
> this was the first suggestion I found when looking online:
>
> ocra rubyfile.rb --windows C:\Ruby192\lib\tcltk\ --no-autoload
> --add-all-core
>
> Add in your own script & tk directory.
It worked! Thank you! It seems I'm not good in searching solutions :)
This topic is locked and can not be replied to.