[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[ANN] RubyScript2Exe 0.2.0

Erik Veenstra

12/8/2004 1:45:00 PM


I just want to say that RubyScript2Exe 0.2.0 [1] has been
released. Both Windows and Linux are supported.

gegroet,
Erik V.

[1] http://www.erikveen.dds.nl/rubyscript2exe/...

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

RubyScript2Exe transforms your Ruby script into a standalone
Windows or Linux 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 exe-file (Windows) or bin-file (Linux). And that's
what we want!

Because of the gathering of files from your own Ruby
installation, RubyScript2Exe creates an executable for the
platform it's being run on. No cross compile.

And when I say Windows, I mean both Windows (RubyInstaller,
MinGW and MSWin32) and Cygwin. But the generated exe under
Cygwin is very, very big, because its exe's are very big
(static?) and it includes cygwin1.dll, so it can run on
machines without Cygwin.

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

27 Answers

Florian Gross

12/8/2004 2:16:00 PM

0

Erik Veenstra wrote:

> I just want to say that RubyScript2Exe 0.2.0 [1] has been
> released. Both Windows and Linux are supported.

Is a change list available somewhere? I couldn't find one on the homepage.

Also while I'm writing to you, would it be possible to allow custom
..DLLs and resources to be added? I have an application that uses a C++
extension which loads more .DLLs -- RubyScript2Exe does not
automatically include those and I can't find a way of manually including
them that works. (I can unpack and repackage, but then the .DLLs will
still not get loaded from the temporary directory.)

Being able to easily include own media would also be very nifty in my
use case. (I'm writing games with Ruby -- it's always nice to have a
single EXE distribution that contains all the game media.)

Thank you for a great library!

Erik Veenstra

12/8/2004 2:40:00 PM

0

On Wed, 08 Dec 2004 15:16:02 +0100, Florian Gross wrote:

> Erik Veenstra wrote:
>
> > I just want to say that RubyScript2Exe 0.2.0 [1] has been
> > released. Both Windows and Linux are supported.
>
> Is a change list available somewhere? I couldn't find one on
> the homepage.

It's there, really... The Download section [1] has a link to
both [2] and [3]. I think you are interested in [2].

> Also while I'm writing to you, would it be possible to allow
> custom .DLLs and resources to be added? I have an application
> that uses a C++ extension which loads more .DLLs --
> RubyScript2Exe does not automatically include those and I
> can't find a way of manually including them that works. (I
> can unpack and repackage, but then the .DLLs will still not
> get loaded from the temporary directory.)

There's a link to Tar2RubyScript [4] on the page as well.
Tar2RubyScript generates a standalone Ruby script from an
existing directory, which contains a complete Ruby application
(scripts, DLL's and resources). This standalone Ruby script can
be converted to an executable with RubyScript2Exe.

That's how I distribute all my applications, complete with
resources, help files, licenses, readme, images, default
configurations, everything. Even including the graphical front
end (WXRuby or RubyWebDialogs [5]). And it just works...

> Being able to easily include own media would also be very
> nifty in my use case. (I'm writing games with Ruby -- it's
> always nice to have a single EXE distribution that contains
> all the game media.)
>
> Thank you for a great library!

[1] http://www.erikveen.dds.nl/rubyscript2exe/index.html#6...
[2] http://www.erikveen.dds.nl/rubyscript2exe/dow...
[3] http://www.erikveen.dds.nl/rubyscript2exe/histor...
[4] http://www.erikveen.dds.nl/tar2rubyscript/...
[5] http://www.erikveen.dds.nl/rubywebdialogs/...

Its Me

12/8/2004 2:45:00 PM

0

"Erik Veenstra" <pan@erikveen.dds.nl> wrote in message

> I just want to say that RubyScript2Exe 0.2.0 [1] has been
> released. Both Windows and Linux are supported.

Will this support all manner of 'require'd files, including those loaded by
the gems require-hack?

Thanks!


Erik Veenstra

12/8/2004 3:47:00 PM

0

> "Erik Veenstra" <pan@erikveen.dds.nl> wrote in message
>
> > I just want to say that RubyScript2Exe 0.2.0 [1] has been
> > released. Both Windows and Linux are supported.
>
> Will this support all manner of 'require'd files, including
> those loaded by the gems require-hack?

Never worked with gems before...

I did a test (on Linux) with the progressbar example. Yes,
RubyScript2Exe detects progressbar.rb [1] and yes, it is
included in the executable [2]. But when the executable is run,
require_gem only searches for progressbar.rb in its own dirs,
not in the regular places. Resulting in an Gem::LoadError. If I
catch this exception, it does work. See below.

I'll have a look at it.

Thanks.

gegroet,
Erik V.

[1] /usr/local/lib/ruby/gems/1.8/gems/progressbar-0.0.3/lib/progressbar.rb
[2] ./lib/progressbar.rb

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

Development machine:

[erik@devel]$ ruby rubyscript2exe.rb testgem.rb
Tracing testgem...
Gathering files...% |oooooooooooooooooooooooooooooooooooooooo| ETA: 00:00:00
Copying files...
Copying /lib/ld-linux.so.2 ...
Copying /usr/local/bin/ruby ...
Copying /scratch/testgem.rb ...
Creating testgem.bin ...

Test machine:

[erik@test1]$ ./testgem.bin
Example progr: 100% |oooooooooooooooooooooooooooooooooooooooo| ETA: 00:00:00

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

# Doesn't work.

require 'rubygems'
require_gem 'progressbar'

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

# Does work.

require 'rubygems'
begin
require_gem 'progressbar'
rescue Gem::LoadError
require 'progressbar'
end

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

Gavin Sinclair

12/8/2004 3:56:00 PM

0

On Thursday, December 9, 2004, 2:47:29 AM, Erik wrote:

>> Will this support all manner of 'require'd files, including
>> those loaded by the gems require-hack?

> [......]

> ----------------------------------------------------------------
>
> # Doesn't work.
>
> require 'rubygems'
> require_gem 'progressbar'
>
> ----------------------------------------------------------------
>
> # Does work.
>
> require 'rubygems'
> begin
> require_gem 'progressbar'
> rescue Gem::LoadError
> require 'progressbar'
> end
>
> ----------------------------------------------------------------

Try:

require 'rubygems'
require 'progressbar'

Cheers,
Gavin




Its Me

12/8/2004 4:19:00 PM

0


"Gavin Sinclair" <gsinclair@soyabean.com.au> wrote in message
> Try:
>
> require 'rubygems'
> require 'progressbar'

Will this allow nested (gem and non-gem) requires within 'progressbar' to
work?

Is the "ruby -r ubygems myfile.rb" and then just plain "require progressbar"
no longer recommended? Or the environment variable GEM_PATH (on WinXP) ?

I am trying to settle on one standard way to use my gems transparently i.e.
without something like 'require_gem' (or was that 'gem_require'?). While
GEM_PATH seems to work, it appears to cause problems with other apps or libs
that assume Rubys standard directory layout.

Advice?


Mauricio Fernández

12/8/2004 4:58:00 PM

0

On Thu, Dec 09, 2004 at 01:22:30AM +0900, itsme213 wrote:
>
> "Gavin Sinclair" <gsinclair@soyabean.com.au> wrote in message
> > Try:
> >
> > require 'rubygems'
> > require 'progressbar'
>
> Will this allow nested (gem and non-gem) requires within 'progressbar' to
> work?

require 'foo' will always load the version from RubyGems, if you're
referring to that. Once you require 'rubygems', it overrides
Kernel.require and it is no longer possible to load the files in the
standard library dir, unless you use the GEM_SKIP env. variable.

> Is the "ruby -r ubygems myfile.rb" and then just plain "require progressbar"
> no longer recommended? Or the environment variable GEM_PATH (on WinXP) ?

ruby -rubygems foo is equivalent to doing a require 'rubygems'...

--
Hassle-free packages for Ruby?
RPA is available from http://www.rubyar...


James Gray

12/8/2004 5:03:00 PM

0

On Dec 8, 2004, at 10:57 AM, Mauricio Fernández wrote:

> On Thu, Dec 09, 2004 at 01:22:30AM +0900, itsme213 wrote:
>>
>> "Gavin Sinclair" <gsinclair@soyabean.com.au> wrote in message
>>> Try:
>>>
>>> require 'rubygems'
>>> require 'progressbar'
>>
>> Will this allow nested (gem and non-gem) requires within
>> 'progressbar' to
>> work?
>
> require 'foo' will always load the version from RubyGems, if you're
> referring to that. Once you require 'rubygems', it overrides
> Kernel.require and it is no longer possible to load the files in the
> standard library dir, unless you use the GEM_SKIP env. variable.

Hmm, is this a good thing? If Ruby Gems replaces the require(),
couldn't it be set to try the old require() when a Gem require fails?
Just a thought.

James Edward Gray II




Mauricio Fernández

12/8/2004 5:32:00 PM

0

On Thu, Dec 09, 2004 at 02:02:37AM +0900, James Edward Gray II wrote:
> On Dec 8, 2004, at 10:57 AM, Mauricio Fernández wrote:
>
> >On Thu, Dec 09, 2004 at 01:22:30AM +0900, itsme213 wrote:
> >>
> >>"Gavin Sinclair" <gsinclair@soyabean.com.au> wrote in message
> >>>Try:
> >>>
> >>> require 'rubygems'
> >>> require 'progressbar'
> >>
> >>Will this allow nested (gem and non-gem) requires within
> >>'progressbar' to
> >>work?
> >
> >require 'foo' will always load the version from RubyGems, if you're
> >referring to that. Once you require 'rubygems', it overrides
> >Kernel.require and it is no longer possible to load the files in the
> >standard library dir, unless you use the GEM_SKIP env. variable.
>
> Hmm, is this a good thing? If Ruby Gems replaces the require(),
> couldn't it be set to try the old require() when a Gem require fails?
> Just a thought.

I didn't phrase that correctly. require 'foo' will load preferentially
the file in the gemdir (instead of the one in sitelibdir as usual).

--
Hassle-free packages for Ruby?
RPA is available from http://www.rubyar...


Erik Veenstra

12/8/2004 5:33:00 PM

0

> > > Will this support all manner of 'require'd files,
> > > including those loaded by the gems require-hack?
> >
> > [......]
>
> Try:
>
> require 'rubygems'
>
> require 'progressbar'

$ grep * -wie def | grep -wie require
loadpath_manager.rb: def require(file)

Looks like RubyGems does an overwrite of Kernel.require:

module Kernel
alias require__ require
def require(file)
Gem::LoadPathManager.search_loadpath(file) || Gem::LoadPathManager.search_gempath(file)
require__(file)
end
end

That will do the trick in our application. But what happens
when a library does a require_gem? Time for the next test. I
don't know Rails, but I think it has some dependencies. Just
giving it a shot...

Test 1:

$ cat test1.rb
require "rubygems"
require_gem "rails"

$ ruby test1.rb

Looks good. It's useless, but the dependencies are fullfilled.

Test 2:

$ cat test2.rb
require "rubygems"
require "rails"

$ ruby test2.rb
/usr/local/lib/ruby/site_ruby/1.8/rubygems/loadpath_manager.rb:5:in `require__': No such file to load -- rails (LoadError)
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/loadpath_manager.rb:5:in `require'
from test2.rb:2

Oops! I think it hasn't anything to do with dependencies. The
trick doesn't work.

Any RubyGem hacker, out there?

gegroet,
Erik V.