[ANN] RubyScript2Exe 0.3.3

RubyScript2Exe 0.3.3 is released!

RubyScript2Exe transforms your Ruby script into a standalone,
compressed Windows, Linux or Max OS X (Darwin) executable. You
can look at it as a "compiler". Not in the sense of a
source-code-to-byte-code compiler, but as a "collector", for it
collects all necessary files to run your script on an other
machine: the Ruby script, the Ruby interpreter and the Ruby
runtime library (stripped down for this script). Anyway, the
result is the same: a standalone executable (application.exe).
And that's what we want!

gegroet,
Erik V.

···

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

Changes:

* newlocation is an absolute path.

* ENV["TEMP"] is an absolute path.

* Added REQUIRE2LIB.

* Added RUBYSCRIPT2EXE.

* Added --rubyscript2exe-nostrip.

* Added RUBYSCRIPT2EXE_BIN.

* Added RUBYSCRIPT2EXE_LIB.

* Fixed the non-SH-compatible shell (e.g. TCSH) bug.

* Changed the name of the generated executable on Linux from
  application.bin to application_linux.

* Added (experimental) support for Mac OS X (Darwin).

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

Erik Veenstra wrote:

RubyScript2Exe 0.3.3 is released!

~/minirubywiki> rubyscript2exe.cmd miniWiki.rb
Tracing miniWiki ...
(offline mode: enter name=value pairs on standard input)

My application is demanding CGI input variables that your app cannot
provide.

(I suppose I'l push them on the command line, then run your app.)

Otherwise, preemptive congrats are probably in order!

···

--
  Phlip
  http://industrialxp.org/community/bin/view/Main/TestFirstUserInterfaces

This is one of the most needed project for ruby. Thanks a million. I am
trying to create an executable for simple tkhello program under
windows. It creates an exe but when I execute it, it throws following
error: Can't find usuable init.tcl

Here is program:

···

---------------------------------------------------------------------
require "tk"
TkButton.new(nil,
             :text => 'hello',
             :command => proc{print "hello\n"}).pack(:fill=>'x')
TkButton.new(nil,
             :text => 'quit',
             :command => proc{exit}).pack(:fill=>'x')
Tk.mainloop
---------------------------------------------------------------------

And I made an executable by typing following in command prompt:
ruby init.rb tkhello.rb

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

Erik Veenstra wrote:

RubyScript2Exe 0.3.3 is released!

RubyScript2Exe transforms your Ruby script into a standalone,
compressed Windows, Linux or Max OS X (Darwin) executable. You
can look at it as a "compiler". Not in the sense of a
source-code-to-byte-code compiler, but as a "collector", for it
collects all necessary files to run your script on an other
machine: the Ruby script, the Ruby interpreter and the Ruby
runtime library (stripped down for this script). Anyway, the
result is the same: a standalone executable (application.exe).
And that's what we want!

gegroet,
Erik V.

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

Changes:

* newlocation is an absolute path.

* ENV["TEMP"] is an absolute path.

* Added REQUIRE2LIB.

* Added RUBYSCRIPT2EXE.

* Added --rubyscript2exe-nostrip.

* Added RUBYSCRIPT2EXE_BIN.

* Added RUBYSCRIPT2EXE_LIB.

* Fixed the non-SH-compatible shell (e.g. TCSH) bug.

* Changed the name of the generated executable on Linux from
  application.bin to application_linux.

* Added (experimental) support for Mac OS X (Darwin).

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

meruby@gmail.com wrote:

This is one of the most needed project for ruby. Thanks a million. I am
trying to create an executable for simple tkhello program under
windows. It creates an exe but when I execute it, it throws following
error: Can't find usuable init.tcl

I haven't looked at this latest release, and perhaps this is not really the issue, but about a month ago I assembled a Web testing app that kicked off WEBrick, launched a browser, and gave the user a choice of test scripts to load and run. However, because these test script were dynamically loaded, RubyScript2Exe did not know to include them in the exe bundle.

I added in some code that did some (gratuitous) calls to 'require' so that all needed code and resources were available.

This likely isn't an option for 'init.tcl', but is there some other way to tell RubyScript2Exe to bundle up an explicit set of files?

James

···

--

http://catapult.rubyforge.com
http://orbjson.rubyforge.com
http://ooo4r.rubyforge.com
http://www.jamesbritt.com

Few further testing on GUI application under windows:
tcl based application throws same error as tk based application
opengl base application hangs and hence it does not even create exe
file

Good news is: wxRuby based application works great. Just one execuable,
small enough size and runs perfectly fine. I will test few things under
linux and will report them here.

Erik Veenstra wrote:

> RubyScript2Exe 0.3.3 is released!

~/minirubywiki> rubyscript2exe.cmd miniWiki.rb
Tracing miniWiki ...
(offline mode: enter name=value pairs on standard input)

My application is demanding CGI input variables that your app cannot
provide.

(I suppose I'l push them on the command line, then run your app.)

Nooope:

~/minirubywiki> QUERY_STRING=query1=value1
~/minirubywiki> REQUEST_METHOD=GET
~/minirubywiki> rubyscript2exe.cmd miniWiki.rb
Tracing miniWiki ...
(offline mode: enter name=value pairs on standard input)

CGI.rb ain't seeing those environmental variables. I have to Ctrl+C the run;
then the rest of rubyscript2exe.cmd works.

BTW the EXE works great - on my populated notebook. I'l congratulate again
when I run it on a virgin 'puter!

···

--
  Phlip
  http://industrialxp.org/community/bin/view/Main/TestFirstUserInterfaces

Few further testing on GUI application under windows:
tcl based application throws same error as tk based application
opengl base application hangs and hence it does not even create exe
file

would something like this quick'n dirty hack do the trick ?

begin
   require "/path/to/your/init.tcl"
rescue
end

But then I haven't been able to use WinXP's .manifest files
for SWin to use the WinXP native look and feel

Few further testing on GUI application under windows: tcl
based application throws same error as tk based application

You still need to install TK itself on the second machine. TK
is not part of Ruby and, as such, is not embedded by
RubyScript2Exe. The bindings between Ruby and TK are part of
the Ruby environment and are embedded by RubyScript2Exe.

If you have a look at init.rb in rubyscript2exe.tar.gz [1], you
find an unused piece of code which tries to handle tk. Because
I don't know how to build TK applications, I'm not quiet sure
whether this works under all circumstances. At least, it used
to work with some of the demos... Is somebody able and willing
to test and correct this code?

Good news is: wxRuby based application works great. Just one
execuable, small enough size and runs perfectly fine. I will
test few things under linux and will report them here.

WxRuby (on Windows) does native calls to the OS to show the
widgets. It doesn't depend on additional libraries. Although it
does depend on such libraries on Linux (e.g. Motif or GTK, (or
is it GDK?)), because there is no such thing as "native
widgets" on Linux...

RubyWebDialogs [2] is pure Ruby, so it works perfectly in
combination with RubyScript2Exe.

gegroet,
Erik V.

[1]
http://www.erikveen.dds.nl/rubyscript2exe/download/rubyscript2exe.tar.gz
[2] http://www.erikveen.dds.nl/rubywebdialogs/index.html

Under Linux:
  tcl/tk application compiles to executable fine.
  qtruby base application throws following error during compilation:

-------------------program-----------------------
[spatel@taamportable rubyscript2exe]$ cat t1.rb
require 'Qt'
a = Qt::Application.new(ARGV)
hello = Qt::PushButton.new('Hello World!', nil)
hello.resize(100, 30)
a.setMainWidget(hello)
hello.show()
a.exec()

···

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

[spatel@taamportable rubyscript2exe]$ ruby init.rb t1.rb
Tracing t1 ...
Gathering files...
/usr/lib/ruby/1.8/ftools.rb:209:in `method_missing': mkdir is not a
class method (ArgumentError)
        from /usr/lib/ruby/1.8/ftools.rb:209:in `makedirs'
        from /usr/lib/ruby/1.8/ftools.rb:202:in `each'
        from /usr/lib/ruby/1.8/ftools.rb:202:in `makedirs'
        from /home/spatel/rubyscript2exe/require2lib.rb:44:in
`gatherlibs'
        from /home/spatel/rubyscript2exe/require2lib.rb:38
        from /home/spatel/rubyscript2exe/require2lib.rb:35
init.rb:99:in `load': No such file to load --
/tmp/oldandnewlocation.7482/require2lib2rubyscript2exe.rb (LoadError)
        from init.rb:99

> Few further testing on GUI application under windows: tcl
> based application throws same error as tk based application

You still need to install TK itself on the second machine. TK
is not part of Ruby and, as such, is not embedded by
RubyScript2Exe. The bindings between Ruby and TK are part of
the Ruby environment and are embedded by RubyScript2Exe.

If you have a look at init.rb in rubyscript2exe.tar.gz [1],
you find an unused piece of code which tries to handle tk.
Because I don't know how to build TK applications, I'm not
quiet sure whether this works under all circumstances. At
least, it used to work with some of the demos... Is somebody
able and willing to test and correct this code?

I activated the TK-code, "compiled" you example (on Linux),
uploaded it to the compile farm of SourceForge (no Ruby, even
no X), started the application and voila: it works!

Shell A:

$ ruby rubyscript2exe.rb test.rb
$ tar c test_linux | nc -l -p -w 5

Shell B:

$ ssh -X -R 1234:localhost:1234 .....
$ nc localhost 1234 | tar x
$ ./test_linux

I've no Windows at hand, so I can't test it. Anybody?

gegroet,
Erik V.

/usr/lib/ruby/1.8/ftools.rb:209:in `method_missing': mkdir is
not a class method (ArgumentError)

Qt defines Dir in its own module. Ruby's ftools.rb somehow uses
this Dir, instead of the top level Dir.

I reduced this test to this little script. Just try to run it
without RubyScript2Exe. It refuses to create directory test4.

If you change "class << File" to "class File", it just works
fine. What's the difference, anyway?

Unfortunately, it has nothing to do with RubyScript2Exe itself.
If it did, I could easily change it...

gegroet,
Erik V.

···

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

puts "START"

Dir.rmdir "test1" if File.directory?("test1")
Dir.rmdir "test2" if File.directory?("test2")
Dir.rmdir "test3" if File.directory?("test3")
Dir.rmdir "test4" if File.directory?("test4")

Dir.mkdir "test1"

class << File
   Dir.mkdir "test2"
end

require "Qt"

Dir.mkdir "test3"

class << File
   Dir.mkdir "test4"
end

puts "END"

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

yes, and it's a great library for ruby...i'm mostly familiar with tk
having worked with tcl/tk and perl/tk, but rubywebdialogs has been the
quickest way for put an interface on my ruby programs AND make them
web enabled at that same time...
http://home.cogeco.ca/~tsummerfelt1
telnet://ventedspleen.dyndns.org

···

On Mon, 28 Mar 2005 17:34:47 +0900, you wrote:

RubyWebDialogs [2] is pure Ruby, so it works perfectly in
combination with RubyScript2Exe.

qtruby base application throws following error during
compilation:

/usr/lib/ruby/1.8/ftools.rb:209:in `method_missing': mkdir is
not a class method (ArgumentError)

This error was caused by a "hack" in QtRuby, which had some
side affects of which the (original) author wasn't aware.
Richard Dale released QtRuby 1.0.8 with a more straightforward
replacement of the "hack":

"An 'include Qt' statement in qtruby.rb where a couple of
methods were being added to class Module was causing all the Qt
methods to be added to Module. Oops, this a really serious bug.
Various methods in qtruby.rb are now module methods in the
Qt::Internal module."

The QT example now works when "compiled" with RubyScript2Exe.

RubyScript2Exe has not been changed.

gegroet,
Erik V.

May be Richard Dale has a solution for this?

"class << file" changes Dirs' ancestors by Qt.

···

-----------------------------------------------------------------------
[spatel@taamportable test]$ cat x.rb
class << File
    p 'Dir ancetors: '
    p Dir.ancestors
end

require "Qt"

class << File
    p 'Dir ancetors after import Qt: '
    p Dir.ancestors
end

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

[spatel@taamportable test]$ ruby x.rb
"Dir ancetors: "
[Dir, Enumerable, Object, Kernel]
"Dir ancetors after import Qt: "
[Qt::Dir, Qt::Base, Object, PP::ObjectMixin, Kernel]
[spatel@taamportable test]$

May be Richard Dale has a solution for this?

"class << file" changes Dirs' ancestors by Qt.

···

-----------------------------------------------------------------------
[spatel@taamportable test]$ cat x.rb
class << File
    p 'Dir ancetors: '
    p Dir.ancestors
end

require "Qt"

class << File
    p 'Dir ancetors after import Qt: '
    p Dir.ancestors
end

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

[spatel@taamportable test]$ ruby x.rb
"Dir ancetors: "
[Dir, Enumerable, Object, Kernel]
"Dir ancetors after import Qt: "
[Qt::Dir, Qt::Base, Object, PP::ObjectMixin, Kernel]
[spatel@taamportable test]$

May be Richard Dale has a solution for this?

"class << file" changes Dirs' ancestors by Qt.

At the end of "Qt/qtruby.rb", "Qt" is included in class
"Module":

class Module
   include Qt
end

This affects all other code in the application! The test script
below shows the consequences.

Is that funny?... Not!

(Somehow, test 24 does work...)

gegroet,
Erik V.

···

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

puts "BEFORE"
p [11, Module.included_modules]
p [12, Module.ancestors]
class << File
   p [13, ancestors]
end
class File
   p [14, ancestors]
end

require "Qt"

puts "AFTER"
p [21, Module.included_modules]
p [22, Module.ancestors]
class << File
   p [23, ancestors]
end
class File
   p [24, ancestors]
end

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

BEFORE
[11, [Kernel]]
[12, [Module, Object, Kernel]]
[13, [Class, Module, Object, Kernel]]
[14, [File, IO, File::Constants, Enumerable, Object, Kernel]]
AFTER
[21, [Qt, Qt::Internal, Kernel]]
[22, [Module, Qt, Qt::Internal, Object, Kernel]]
[23, [Class, Module, Qt, Qt::Internal, Object, Kernel]]
[24, [File, IO, File::Constants, Enumerable, Object, Kernel]]

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

Erik Veenstra wrote:

May be Richard Dale has a solution for this?

"class << file" changes Dirs' ancestors by Qt.

At the end of "Qt/qtruby.rb", "Qt" is included in class
"Module":

class Module
   include Qt
end

This affects all other code in the application! The test script
below shows the consequences.

Is that funny?... Not!

(Somehow, test 24 does work...)

Oh dear! I got Erik's email about the bug, and I'm having a look at it. It
seems a serious problem - I've had unexpected problems with namespaces
before, and I think this is what's causing it.

-- Richard