Computer Science Canada

Ruby Script to .exe

Author:  [Gandalf] [ Fri Aug 26, 2005 2:54 am ]
Post subject:  Ruby Script to .exe

Well, I finally got around to trying this out, and it works like a charm Smile.

All you need is a single ruby file, and you just add it before your own ruby program to compile:
code:
ruby rubyscript2exe.rb HelloWorld.rb

You have the option of adding some parameters if you like, but they are not neccessary as default is fine.

Anways, I was just going to ask someone to test out the .exe (someone who doesn't have Ruby installed) to see if it works. The final executable is smaller than a Turing executable, at least under windows - the following code "compiled" to 665kb as opposed to Turing's 709kb. I could probably minimize the by using some parameters though (not sure).

Ruby:
puts "Hello"
print "Enter your name: "
name = gets
puts "Hello, #{name}"
exit = gets


Attached is the exe .rar'ed.

Author:  wtd [ Fri Aug 26, 2005 2:59 am ]
Post subject: 

Note: when you run "ruby rubyscript2exe.rb HelloWorld.rb", you're not passing "HelloWorld.rb" to ruby itself. You're passing it to the application created by running "ruby rubyscript2exe.rb".

Author:  Hikaru79 [ Fri Aug 26, 2005 8:15 am ]
Post subject: 

Works great for me Smile Now, what I'm curious about is, if you use some third-party libraries that you install, will it be smart enough to package those too by default, or do you have to manually specify those to the program?

Author:  wtd [ Fri Aug 26, 2005 3:50 pm ]
Post subject: 

I would further suggest installing this via the gem.

Just:

code:
gem install rubyscript2exe.gem


Then you should just be able to call:

code:
rubyscript2exe HelloWorld.rb

Author:  wtd [ Fri Aug 26, 2005 3:54 pm ]
Post subject: 

Hikaru79 wrote:
Works great for me Smile Now, what I'm curious about is, if you use some third-party libraries that you install, will it be smart enough to package those too by default, or do you have to manually specify those to the program?


code:
~/Desktop $ cat > hello.rb
def say_hello
   puts "Hello!"
end
~/Desktop $ cat > application.rb
require "hello"

say_hello
~/Desktop $ rubyscript2exe application.rb
Tracing application ...
Hello!
Gathering files...
Copying files...
Stripping...
Creating application_linux ...
~/Desktop $ ./application_linux
Hello!
~/Desktop $

Author:  [Gandalf] [ Fri Aug 26, 2005 7:34 pm ]
Post subject: 

Well then looks good Smile.
Now I have to try some other things with it, like with that tar2rubyscript and some other things.

I noticed that although the executable is smaller than Turing's, the reason is that it is already heavily compressed, while Turing's is not. Therefore, if you try to compress the Ruby .exe, it will not seem as effective as with a Turing .exe.

Author:  wtd [ Fri Aug 26, 2005 7:51 pm ]
Post subject: 

In an era of widespread broadband and large hard drives... does it really matter?

Author:  [Gandalf] [ Fri Aug 26, 2005 8:08 pm ]
Post subject: 

Well... It's always nice to have something smaller. If I compiled my whole programming directory on this comp that would be a gigabyte instead of a managable 25mb of source. If I had each of those compressed though, that would be 4 times less to carry around, and 4 times faster to store, download, move, scan, or whatever you are doing.
There are also cases like when you have a cheap website, say 20mb, where having a 100kb file is better than a 1mb one.

Author:  wtd [ Fri Aug 26, 2005 8:11 pm ]
Post subject: 

Then just store the Ruby script there and simply ask people to install Ruby. Smile

Author:  Tony [ Fri Aug 26, 2005 8:33 pm ]
Post subject: 

[Gandalf] wrote:
Well... It's always nice to have something smaller.

Unless we're not talking about space your program takes up Laughing

Seriously though, just keep Ruby as is and let users install the interpreter. Not everybody can run .exe's anyways.

Author:  wtd [ Fri Aug 26, 2005 8:41 pm ]
Post subject: 

Tony wrote:
[Gandalf] wrote:
Well... It's always nice to have something smaller.

Unless we're not talking about space your program takes up Laughing

Seriously though, just keep Ruby as is and let users install the interpreter. Not everybody can run .exe's anyways.


Indeed. You'd have to store versions for Windows, Linux, and Mac OS X, as well as probably having versions on hand for numerous other *nixes.

Author:  [Gandalf] [ Sat Aug 27, 2005 3:41 am ]
Post subject: 

Laughing Well... Ya... It was in my comparison to Turing though, and the same applies to it.

I'm not going to be making commercial programs with it (obviously), but I just like to have the reassurance that I can use my program on another computer without installing Ruby.

Anyways, tomorrow I will try to learn a bit more Ruby to try and put all this to use Smile.

Author:  wtd [ Sat Aug 27, 2005 3:52 am ]
Post subject: 

[Gandalf] wrote:
I'm not going to be making commercial programs with it (obviously)


Why not? Smile

Ruby's certainly capable.

Author:  [Gandalf] [ Sat Aug 27, 2005 3:57 am ]
Post subject: 

It's myself that's not capable Wink.

No, but my point was that I will not be distributing my programs to many people in the near future, so it doesn't matter as much.

Author:  wtd [ Sat Aug 27, 2005 4:15 am ]
Post subject: 

[Gandalf] wrote:
It's myself that's not capable Wink.


That'll change.

Author:  yuyumo [ Sun Aug 21, 2011 11:12 am ]
Post subject:  Re: Ruby Script to .exe

Hi,
I've Netbeans 6.9.1 and I installed the rubyscript2exe.rb in the Shell with:
code:
gem install rubyscript2exe.gem

It was successful.

Now, I'm trying to convert my main.rb with it, but it doesn't work!

First I put this line on the top of the code of my main.rb:
code:
rubyscript2exe main.rb


Secondly I tried to convert it to exe in the shell with this command:
code:
gem rubyscript2exe main.rb

Here I'm getting the following:

code:

C:\Programme\NetBeans 6.9.1\ruby\jruby-1.5.1\bin>rubyscript2exe main.rb
Couldn't create file rubyscript2exe/CHANGELOG: No such file or directory - rubyscript2exe/CHANGELOG
Couldn't create file rubyscript2exe/eee.ico: No such file or directory - rubyscript2exe/eee.ico
Couldn't create file rubyscript2exe/eee.rc: No such file or directory - rubyscript2exe/eee.rc
Couldn't create file rubyscript2exe/init.rb: No such file or directory - rubyscript2exe/init.rb
Couldn't create file rubyscript2exe/LICENSE: No such file or directory - rubyscript2exe/LICENSE
Couldn't create file rubyscript2exe/README: No such file or directory - rubyscript2exe/README
Couldn't create file rubyscript2exe/SUMMARY: No such file or directory - rubyscript2exe/SUMMARY
Couldn't create file rubyscript2exe/VERSION: No such file or directory - rubyscript2exe/VERSION
Couldn't create file rubyscript2exe/ev/ftools.rb: No such file or directory - rubyscript2exe/ev/ftools.rb
Couldn't create file rubyscript2exe/ev/oldandnewlocation.rb: No such file or directory - rubyscript2exe/ev/oldandnewloca
tion.rb
Couldn't create file rubyscript2exe/ev/dependencies.rb: No such file or directory - rubyscript2exe/ev/dependencies.rb
Couldn't create file rubyscript2exe/rubyscript2exe.rb: No such file or directory - rubyscript2exe/rubyscript2exe.rb
Couldn't create file rubyscript2exe/eee.pas: No such file or directory - rubyscript2exe/eee.pas
Couldn't create file rubyscript2exe/require2lib.rb: No such file or directory - rubyscript2exe/require2lib.rb
Couldn't create file rubyscript2exe/eee.exe: No such file or directory - rubyscript2exe/eee.exe
Couldn't create file rubyscript2exe/eeew.exe: No such file or directory - rubyscript2exe/eeew.exe
Couldn't create file rubyscript2exe/eee_linux: No such file or directory - rubyscript2exe/eee_linux
C:/Programme/NetBeans 6.9.1/ruby/jruby-1.5.1/lib/ruby/gems/1.8/gems/rubyscript2exe-0.5.3/realstuff.rb:395:in `each_objec
t': ObjectSpace is disabled; each_object will only work with Class, pass -X+O to enable (RuntimeError)
        from C:/Programme/NetBeans 6.9.1/ruby/jruby-1.5.1/lib/ruby/gems/1.8/gems/rubyscript2exe-0.5.3/realstuff.rb:395:i
n `extract'
        from C:/Programme/NetBeans 6.9.1/ruby/jruby-1.5.1/lib/ruby/gems/1.8/gems/rubyscript2exe-0.5.3/realstuff.rb:598
        from C:/Programme/NetBeans 6.9.1/ruby/jruby-1.5.1/lib/ruby/gems/1.8/gems/rubyscript2exe-0.5.3/realstuff.rb:7:in
`load'
        from C:/Programme/NetBeans 6.9.1/ruby/jruby-1.5.1/lib/ruby/gems/1.8/gems/rubyscript2exe-0.5.3/bin/rubyscript2exe
:7
        from C:/Programme/NetBeans 6.9.1/ruby/jruby-1.5.1/lib/ruby/gems/1.8/gems/rubyscript2exe-0.5.3/bin/rubyscript2exe
:19:in `load'
        from C:\Programme\NetBeans 6.9.1\ruby\jruby-1.5.1\bin\rubyscript2exe:19

C:\Programme\NetBeans 6.9.1\ruby\jruby-1.5.1\bin>




Thanx for your help!

Author:  Velocity [ Mon Nov 28, 2011 11:12 am ]
Post subject:  RE:Ruby Script to .exe

YOU HAVE TO IDENTIFY THE RB SHELL IN YOUR LIBRARY/RUBY DIRECTORY sorry for caps it was just an obvious mistake or ask tony.


: