Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't like tk gem #29

Closed
catmando opened this issue Aug 18, 2011 · 8 comments
Closed

Doesn't like tk gem #29

catmando opened this issue Aug 18, 2011 · 8 comments

Comments

@catmando
Copy link

Running on windows 7, under the ruby one click installer. ruby 1.8.7 (2011-06-30 patchlevel 352) [i386-mingw32]

I have tried this with both ocra 1.2.0 and 1.3.0, and with both ruby 1.8.7 and 1.9.1/2

requiring the tk gem causes lots of failures. Just for fun I started putting rescues around the failure points in the tk code, but it just went on and on. (note removing the require 'tk' allows the exe to be created) Note also none of the tk code is being called. Its just requiring the gem that is causing the problems.

Here are some samples:

=== Loading script to check dependencies
C:/Ruby192/lib/ruby/1.9.1/tk/console.rb:13:in _create_console': interpreter is deleted (RuntimeError) from C:/Ruby192/lib/ruby/1.9.1/tk/console.rb:13:increate'
from C:/Ruby192/lib/ruby/1.9.1/tk/console.rb:15:in `module:TkConsole'

def self.create
TkCore::INTERP._create_console # LINE 13 #
end
self.create # initialize console

putting a rescue at line 13 gets us to:

=== Loading script to check dependencies
C:/Ruby192/lib/ruby/1.9.1/tk/msgcat.rb:24:in <class:TkMsgCatalog>': RuntimeErro r (RuntimeError) from C:/Ruby192/lib/ruby/1.9.1/tk/msgcat.rb:8:in<top (required)>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:467:in `con
st_get'

tk_call_without_enc('package', 'require', 'Tcl', '8.2') # Line 24 #

this problem is repeated a bunch of places in msgcat

and on it goes...

@catmando
Copy link
Author

I just wanted to let you know that this is still a problem (I was having trouble with which ocra version I was using, but now that I am definitely using 1.3.0, I am reporting this is still happening.

All I need to reproduce is a file like this:

require 'rubygems'
require 'tk'
puts 'bork!'

Cheers!

@emalaga
Copy link

emalaga commented Aug 25, 2011

I am having the same problem. I am using Ruby 1.9.3 on Windows XP. Program is just:

require 'tk'
puts "hello world"

error is:

=== Loading script to check dependencies
hello world
C:/Program Files/Ruby192/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:271: warning: failed to set environment variable. Ruby 1.9.3 will raise SystemCallError in this case.
C:/Program Files/Ruby192/lib/ruby/1.9.1/tk/console.rb:13:in _create_console': interpreter is deleted (RuntimeError) from C:/Program Files/Ruby192/lib/ruby/1.9.1/tk/console.rb:13:increate'
from C:/Program Files/Ruby192/lib/ruby/1.9.1/tk/console.rb:15:in <module:TkConsole>' from C:/Program Files/Ruby192/lib/ruby/1.9.1/tk/console.rb:6:in<top (required)>'
from C:/Program Files/Ruby192/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:467:in const_get' from C:/Program Files/Ruby192/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:467:inblock (3 levels) in attempt_load_autoload'
from C:/Program Files/Ruby192/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:464:in each' from C:/Program Files/Ruby192/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:464:inblock (2 levels) in attempt_load_autoload'
from C:/Program Files/Ruby192/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:462:in each' from C:/Program Files/Ruby192/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:462:inblock in attempt_load_autoload'
from C:/Program Files/Ruby192/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:456:in loop' from C:/Program Files/Ruby192/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:456:inattempt_load_autoload'
from C:/Program Files/Ruby192/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:679:in build_exe' from C:/Program Files/Ruby192/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:1138:inblock in <top (required)>'

Any help would be appreciated. Thanks.

@catmando
Copy link
Author

I had to give up, and ended up using fxruby, which actually I liked a lot better.

If you would like more info on where I ended up for the UI on PC email me directly.

Otherwise OCRA works great.

@emalaga
Copy link

emalaga commented Aug 26, 2011

Good advice, I just installed fxruby using gem and then OCRA built the exe without any problems. I will write my program using fxruby instead of tk. Thanks for your help.

@seiferteric
Copy link

Same issue here, all that is required is a require 'tk' and get this:

C:/Ruby192/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:271: warning: failed to set environment variable. Ruby 1.9.3 will raise SystemCallEr
ror in this case.
C:/Ruby192/lib/ruby/1.9.1/tk/console.rb:13:in _create_console': interpreter is deleted (RuntimeError) from C:/Ruby192/lib/ruby/1.9.1/tk/console.rb:13:increate'
from C:/Ruby192/lib/ruby/1.9.1/tk/console.rb:15:in <module:TkConsole>' from C:/Ruby192/lib/ruby/1.9.1/tk/console.rb:6:in<top (required)>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:467:in const_get' from C:/Ruby192/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:467:inblock (3 levels) in attempt_load_autoload'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:464:in each' from C:/Ruby192/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:464:inblock (2 levels) in attempt_load_autoload'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:462:in each' from C:/Ruby192/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:462:inblock in attempt_load_autoload'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:456:in loop' from C:/Ruby192/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:456:inattempt_load_autoload'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:679:in build_exe' from C:/Ruby192/lib/ruby/gems/1.9.1/gems/ocra-1.3.0/bin/ocra:1138:inblock in <top (required)>'

@mattsgarrison
Copy link

While I don't yet have a full understanding of the problem so I don't have a patch, I was able to package Tk with OCRA and distribute it to others as a self-contained exe without the user needing to install anything else. I encountered this issue with Ruby 1.9.2p290 (2011-07-09) [i386-mingw32] on Windows 7. I used the p290 RubyInstaller which packaged the Tk libraries with the Ruby installation. My app was only requiring the following gems: fileutils, tk, and tkextlib/tile.

The problem is OCRA does some autoloading that Tk doesn't like. By adding the --no--autoload flag to the ocra build, it bypasses the attempt_load_autoload error everyone listed above. However, you'll then run into the following error:

C:/TEMP/AppData/Local/Temp/ocr740C.tmp/lib/ruby/1.9.1/tk.rb:36:in `initialize': Can't find a usable init.tcl in the foll
owing directories:  (RuntimeError)
    C:/TEMP/AppData/Local/Temp/ocr740C.tmp/lib/tcltk/tcl8.5 C:/TEMP/AppData/Local/Temp/ocr740C.tmp/lib/tcl8.5 C:/TEMP/....[truncating additional paths, you don't care]

So after some gratuitous use of the --debug-extract flag and experimentation, if you look at C:\Ruby192\lib\\tcltk\tcl8.5\ you should find the init.tcl file, which isn't getting packaged by OCRA since you turned off autoloading. To fix this, you'll now need to add the C:\Ruby192\lib\\tcltk path to your build command as "additional files and resources" as described in the OCRA wiki, and without autoloading, you might need to --add-all-core and twiddle other packaging knobs to make it include everything your app depends upon (mine was a stupid simple app, something with a boatload of dependencies may be more difficult). The obvious downside to this is that your executable file size will increase since you're packaging more stuff. My ~200 line script is a 5Mb executable now.

TL;DR
Try packaging your Tk Ruby app with the following command, it worked for me:

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

@larsch
Copy link
Owner

larsch commented Mar 28, 2013

Upvote for workaround. This is not "fixable" in ocra (at best a workaround could be made automatic):

Use this (same as mattsgarrison suggests):

ocra --no-autoload --add-all-core tkapp.rb c:\ruby193-p392\lib\tcltk

@larsch larsch closed this as completed Mar 28, 2013
@DavidLKing
Copy link

I'm sure this is super late, but in finding my own problem with this, I found bogbasic's comment here which allowed me to use Tk and Ruby with Ocra: https://www.ruby-forum.com/topic/2981846

"Maybe too late but the thing to do is to copy the ruby file you wish to
compile to the C:\Ruby193\lib folder which contains the tcltk directory
and then run ocra there as follows....

ocra yourfile.rb tcltk --no-autoload

... then you can copy the resulting .exe file to wherever you want
afterwards and it runs fine."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants