# Compiling Ruby code

**URL:** <https://rubytalk.org/t/compiling-ruby-code/12668>\
**Category:** ruby-talk\
**Created:** [20 July 2004 09:50 UTC](https://rubytalk.org/t/compiling-ruby-code/12668 "2004-07-20T09:50:43Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_Roshan\_Cogniza](https://avatars.discourse-cdn.com/v4/letter/j/45deac/32.png) [@James\_Roshan\_Cogniza](https://rubytalk.org/u/James_Roshan_Cogniza)\
**Post date:** [20 July 2004 09:50 UTC](https://rubytalk.org/t/compiling-ruby-code/12668/1 "2004-07-20T09:50:43Z")

</div>

If it is a meaningful additions to this list, I'd like to say that thse  
projects exist -

Groovy  
[http://groovy.codehaus.org/](http://groovy.codehaus.org/)

Jruby  
[http://jruby.sourceforge.net/](http://jruby.sourceforge.net/)

Groovy might be of interst because it is a ruby like language that is  
compiled ot the JVM. The understand being that if it can be compiled to  
the JVM, it can be compiled to native code. It is a powerful flexible  
language like ruby with proper iterator and closure support.

However, as far as I understand, eval style dynamic compilation is not  
yet supported.

I really agree with your sentiment about wanting to compile ruby  
programs for the purpose of redistribution. That's the problem with all  
the ruby code out there - there is no way I can redistribute it without  
asking people download the ruby interpreter.  
And they they go "whats that ?... " and the whole story telling process  
starts.

Taking ruby to a popular VM/runtime or native code, IMHO would be a big  
big addition to the acceptibility of the language. I understand that  
that it is a mind boggling amount of work to do this, in any acceptible  
way.

Regards  
Roshan James

[InterScan\_Disclaimer.txt](https://rubytalk.org/uploads/short-url/2C3THNKxQ9jIXqULnY0IIaOsX5q.txt) (520 Bytes)

---

<div class="post-metadata">

**Author:** ![Ruben](https://avatars.discourse-cdn.com/v4/letter/r/59ef9b/32.png) [@Ruben](https://rubytalk.org/u/Ruben)\
**Post date:** [20 July 2004 10:25 UTC](https://rubytalk.org/t/compiling-ruby-code/12668/2 "2004-07-20T10:25:50Z")

</div>

> I really agree with your sentiment about wanting to compile ruby  
> programs for the purpose of redistribution. That's the problem with all  
> the ruby code out there - there is no way I can redistribute it without  
> asking people download the ruby interpreter.  
> And they they go "whats that ?... " and the whole story telling process  
> starts.

As has been said before, there \_is\_ a way to redistribute your  
application without asking people to download the  
interpreter... Actually, there are 2 ways, the first one is called  
Exerb and the second one is called RubyScript2Exe.

I made a very small test application in ruby, turned it into one  
executable with RubyScript2Exe, then i used HM NIS Edit to make an  
initial script for NSIS (Nullsoft Scriptable Install System), which  
gave me a simple "Setup.exe". I have to admit it was a very, very  
simple thing, but still it surprised me that it went so easy to make a  
good looking installer for it. The only thing the user has to do, is  
to run the "setup.exe", no need to even talk about ruby.

RubyScript2Exe [http://www.erikveen.dds.nl/rubyscript2exe/index.html](http://www.erikveen.dds.nl/rubyscript2exe/index.html)  
NSIS [http://nsis.sourceforge.net/](http://nsis.sourceforge.net/)  
HM NIS Edit [http://hmne.sourceforge.net/](http://hmne.sourceforge.net/)

> Taking ruby to a popular VM/runtime or native code, IMHO would be a big  
> big addition to the acceptibility of the language. I understand that  
> that it is a mind boggling amount of work to do this, in any acceptible  
> way.

I don't really understand why you think it would be a problem to ask  
the user to install the ruby interpreter (the one-click installer),  
since you seem to think it would not be a problem to ask the user to  
first install for example a JVM to run a Java program... ?

That being said, I would love to see a compiler (to bytecode or to  
native code) for ruby too, but then who doesn't ?

Ruben

> **···**
>
> At Tue, 20 Jul 2004 18:50:43 +0900, James, Roshan (Cognizant) wrote:

---

<div class="post-metadata">

**Author:** ![Curt\_Hibbs3](https://avatars.discourse-cdn.com/v4/letter/c/2acd7d/32.png) [@Curt\_Hibbs3](https://rubytalk.org/u/Curt_Hibbs3)\
**Post date:** [20 July 2004 12:36 UTC](https://rubytalk.org/t/compiling-ruby-code/12668/3 "2004-07-20T12:36:25Z")

</div>

Ruben wrote:

> \>  
> \> I really agree with your sentiment about wanting to compile ruby  
> \> programs for the purpose of redistribution. That's the problem with all  
> \> the ruby code out there - there is no way I can redistribute it without  
> \> asking people download the ruby interpreter.  
> \> And they they go "whats that ?... " and the whole story telling process  
> \> starts.
> 
> As has been said before, there \_is\_ a way to redistribute your  
> application without asking people to download the  
> interpreter... Actually, there are 2 ways, the first one is called  
> Exerb and the second one is called RubyScript2Exe.

These are excellent solutions. Unfortunately, they only work for Windows.  
I'm not aware of anything comparable for Mac or 'nix systems.

> I made a very small test application in ruby, turned it into one  
> executable with RubyScript2Exe, then i used HM NIS Edit to make an  
> initial script for NSIS (Nullsoft Scriptable Install System), which  
> gave me a simple "Setup.exe". I have to admit it was a very, very  
> simple thing, but still it surprised me that it went so easy to make a  
> good looking installer for it. The only thing the user has to do, is  
> to run the "setup.exe", no need to even talk about ruby.
> 
> RubyScript2Exe [http://www.erikveen.dds.nl/rubyscript2exe/index.html](http://www.erikveen.dds.nl/rubyscript2exe/index.html)  
> NSIS [http://nsis.sourceforge.net/](http://nsis.sourceforge.net/)  
> HM NIS Edit [http://hmne.sourceforge.net/](http://hmne.sourceforge.net/)
> 
> \> Taking ruby to a popular VM/runtime or native code, IMHO would be a big  
> \> big addition to the acceptibility of the language. I understand that  
> \> that it is a mind boggling amount of work to do this, in any acceptible  
> \> way.
> 
> I don't really understand why you think it would be a problem to ask  
> the user to install the ruby interpreter (the one-click installer),  
> since you seem to think it would not be a problem to ask the user to  
> first install for example a JVM to run a Java program... ?

Again, this would be a Windows-only solution.

Anyone who wants to take this approach can do it without the one-click  
installer -- you can just install a private version of Ruby used only to run  
your app. FreeRIDE does this for its Windows installation (and we have been  
considering doing this for other platforms). If you want to see how this  
works, install FreeRIDE on windows and take a look at the startup script  
"run.bat".

> That being said, I would love to see a compiler (to bytecode or to  
> native code) for ruby too, but then who doesn't ?

Me, too! Anyone who is really interested in this and has some available time  
should considering helping the Cardinal project get ruby working with the  
Parrot VM.

Curt

> **···**
>
> > At Tue, 20 Jul 2004 18:50:43 +0900, \> James, Roshan (Cognizant) wrote:

---

<div class="post-metadata">

**Author:** ![Ruben](https://avatars.discourse-cdn.com/v4/letter/r/59ef9b/32.png) [@Ruben](https://rubytalk.org/u/Ruben)\
**Post date:** [20 July 2004 13:56 UTC](https://rubytalk.org/t/compiling-ruby-code/12668/4 "2004-07-20T13:56:11Z")

</div>

> These are excellent solutions. Unfortunately, they only work for Windows.  
> I'm not aware of anything comparable for Mac or 'nix systems.

Yep, you are right, it would be interesting to have tools similar as  
Exerb and RubyScript2Exe for Mac, Linux and BSD systems. And an  
installer on those platforms would also be nice (maybe Loki  
installer).

> \> I don't really understand why you think it would be a problem to ask  
> \> the user to install the ruby interpreter (the one-click installer),  
> \> since you seem to think it would not be a problem to ask the user to  
> \> first install for example a JVM to run a Java program... ?
> 
> Again, this would be a Windows-only solution.

Wasn't it mentioned before on the list that work is planned/ongoing  
for making a one-click installer on other platforms ?

> Anyone who wants to take this approach can do it without the one-click  
> installer -- you can just install a private version of Ruby used only to run  
> your app. FreeRIDE does this for its Windows installation (and we have been  
> considering doing this for other platforms). If you want to see how this  
> works, install FreeRIDE on windows and take a look at the startup script  
> "run.bat".

If i would 'package' a ruby application for linux, then i would either  
do as you said (the ruby interpreter is not that big and then you're  
sure your application runs on the ruby version you tested/developed it  
on), or either i would make a package (ebuild for Gentoo, rpm for  
redhat/mandrake, deb for debian) that depends on the ruby-package  
(this has the advantage that you can easily upgrade the ruby  
interpreter for better performance, bugfixes,...).

(Now that i think about it, most commercial java-applications do  
include a specific JVM in the installation, don't they ?)

> \> That being said, I would love to see a compiler (to bytecode or to  
> \> native code) for ruby too, but then who doesn't ?
> 
> Me, too! Anyone who is really interested in this and has some available time  
> should considering helping the Cardinal project get ruby working with the  
> Parrot VM.

".. has some available time..." i think that's the biggest problem  
for a lot of people... Even if you're knowledgeable enough about  
compilers, then it still takes some time to 'get into' the Cardinal  
project and see what they have and how things work, before you can  
really contribute to it. (at least, that's how i feel about it)

Ruben

> **···**
>
> At Tue, 20 Jul 2004 21:36:25 +0900, Curt Hibbs wrote:

---

<div class="post-metadata">

**Author:** ![Dave\_Baldwin](https://avatars.discourse-cdn.com/v4/letter/d/e95f7d/32.png) [@Dave\_Baldwin](https://rubytalk.org/u/Dave_Baldwin)\
**Post date:** [20 July 2004 16:14 UTC](https://rubytalk.org/t/compiling-ruby-code/12668/5 "2004-07-20T16:14:26Z")

</div>

Under Mac OS X an application presents itself as an executable file, but is in fact a package (i.e. directory). Inside the package is the real executable and any resources (help files, images, sounds, icons, GUI configuration files (nib files), etc.) it needs. It would be easy to include the ruby interpreter and any libraries you need within the package together with your ruby files so I think exerb and friends are probably not needed.

You may even be able to omit the interpreter as Ruby 1.6 is installed as standard (I may be wrong, but I don't think it is part of the developer tools).

Dave.

> **···**
>
> On 20 Jul 2004, at 14:56, Ruben wrote:
> 
> > At Tue, 20 Jul 2004 21:36:25 +0900, \> Curt Hibbs wrote:
> > 
> > > These are excellent solutions. Unfortunately, they only work for Windows.  
> > > I'm not aware of anything comparable for Mac or 'nix systems.
> > 
> > Yep, you are right, it would be interesting to have tools similar as  
> > Exerb and RubyScript2Exe for Mac, Linux and BSD systems. And an  
> > installer on those platforms would also be nice (maybe Loki  
> > installer).

---

<div class="post-metadata">

**Author:** ![Curt\_Hibbs3](https://avatars.discourse-cdn.com/v4/letter/c/2acd7d/32.png) [@Curt\_Hibbs3](https://rubytalk.org/u/Curt_Hibbs3)\
**Post date:** [20 July 2004 17:24 UTC](https://rubytalk.org/t/compiling-ruby-code/12668/6 "2004-07-20T17:24:10Z")

</div>

Ruben wrote:

> Wasn't it mentioned before on the list that work is planned/ongoing  
> for making a one-click installer on other platforms ?

There is no actual work going on. What you read was my desire to add more  
platforms to the Ruby Installer project and my call for help in doing so. So  
far there have been no volunteers.

Curt

---

<div class="post-metadata">

**Author:** ![Erik\_Veenstra3](https://avatars.discourse-cdn.com/v4/letter/e/f9ae1b/32.png) [@Erik\_Veenstra3](https://rubytalk.org/u/Erik_Veenstra3)\
**Post date:** [20 July 2004 23:47 UTC](https://rubytalk.org/t/compiling-ruby-code/12668/7 "2004-07-20T23:47:55Z")

</div>

I think it's possible to make a RubyScript2Exe for Linux. Even  
cross-compiling (both ways) isn't impossible. Are you really  
interested? Would take only a couple of hours... I always  
assumed that every Linux distribution comes with Ruby. Maybe  
not pre-installed, but at least on CD. So I didn't spend any  
time on this issue.

The problem with Linux is how to determine which dependencies  
are to be distributed in the binary. On my system (RH8), Ruby  
(the core and \*.so) needs at least the following files (both  
direct and indirect):

/lib/ld-linux.so.2  
/lib/libNoVersion.so.1  
/lib/libc.so.6  
/lib/libcrypt.so.1  
/lib/libdl.so.2  
/lib/libgcc\_s.so.1  
/lib/libm.so.6  
/lib/libnss\_files.so.2  
/usr/lib/libgdbm.so.2  
/usr/lib/libncurses.so.5  
/usr/lib/libreadline.so.4

Can I assume that these are available on all modern  
distributions, so I only need to distribute /usr/bin/ruby and  
/usr/lib/libruby.so.1.6 (besides the "application-specific"  
stripped rubylib tree)? What about the versions? Is 1.8 more  
complex? How can I test on several distributions,  
cross-distribution? Anybody?

gegroet,  
Erik V.

> **···**
>
> On Tue, 20 Jul 2004 22:56:11 +0900, Ruben wrote:
> 
> > At Tue, 20 Jul 2004 21:36:25 +0900, Curt Hibbs wrote:
> > 
> > \> These are excellent solutions. Unfortunately, they only  
> > \> work for Windows. I'm not aware of anything comparable for  
> > \> Mac or 'nix systems.
> > 
> > Yep, you are right, it would be interesting to have tools  
> > similar as Exerb and RubyScript2Exe for Mac, Linux and BSD  
> > systems. And an installer on those platforms would also be  
> > nice (maybe Loki installer).

---

<div class="post-metadata">

**Author:** ![David\_Ross2](https://avatars.discourse-cdn.com/v4/letter/d/ed8c4c/32.png) [@David\_Ross2](https://rubytalk.org/u/David_Ross2)\
**Post date:** [20 July 2004 19:48 UTC](https://rubytalk.org/t/compiling-ruby-code/12668/8 "2004-07-20T19:48:29Z")

</div>

> It would be easy  
> to include the ruby interpreter and any libraries  
> you need within the  
> package together with your ruby files so I think  
> exerb and friends are  
> probably not needed.

That is not the point of having a native compiler. The  
point of it is to include it into projects which do  
not want the compiler. For example I wanted to include  
a ruby script in this OS, but they said they do not  
want interpreted languages in the base install. This  
also has to do with not wanting to install the ruby  
software. That is why I am making a decision. --David  
Ross

> **···**
>
> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> Do you Yahoo!?  
> Vote for the stars of Yahoo!'s next ad campaign!  
> [http://advision.webevents.yahoo.com/yahoo/votelifeengine/](http://advision.webevents.yahoo.com/yahoo/votelifeengine/)

---

<div class="post-metadata">

**Author:** ![Lothar\_Scholz2](https://avatars.discourse-cdn.com/v4/letter/l/f14d63/32.png) [@Lothar\_Scholz2](https://rubytalk.org/u/Lothar_Scholz2)\
**Post date:** [21 July 2004 05:09 UTC](https://rubytalk.org/t/compiling-ruby-code/12668/9 "2004-07-21T05:09:58Z")

</div>

Hello Erik,

> The problem with Linux is how to determine which dependencies  
> are to be distributed in the binary. On my system (RH8), Ruby  
> (the core and \*.so) needs at least the following files (both  
> direct and indirect):

> /lib/ld-linux.so.2  
> /lib/libNoVersion.so.1  
> /lib/libc.so.6  
> /lib/libcrypt.so.1  
> /lib/libdl.so.2  
> /lib/libgcc\_s.so.1  
> /lib/libm.so.6  
> /lib/libnss\_files.so.2  
> /usr/lib/libgdbm.so.2  
> /usr/lib/libncurses.so.5  
> /usr/lib/libreadline.so.4

> Can I assume that these are available on all modern  
> distributions, so I only need to distribute /usr/bin/ruby and  
> /usr/lib/libruby.so.1.6 (besides the "application-specific"  
> stripped rubylib tree)? What about the versions? Is 1.8 more  
> complex? How can I test on several distributions,  
> cross-distribution? Anybody?

Read Chapter 3 from

[http://www.linuxbase.org/modules.php?name=specrev&url=http://www.linuxbase.org/spec/booksets/LSB-Core/LSB-Core.html](http://www.linuxbase.org/modules.php?name=specrev&url=http://www.linuxbase.org/spec/booksets/LSB-Core/LSB-Core.html)

> **···**
>
> --  
> Best regards, emailto: scholz at scriptolutions dot com  
> Lothar Scholz [http://www.ruby-ide.com](http://www.ruby-ide.com)  
> CTO Scriptolutions Ruby, PHP, Python IDE 's

---

<div class="post-metadata">

**Author:** ![Rando\_Christensen](https://avatars.discourse-cdn.com/v4/letter/r/ed655f/32.png) [@Rando\_Christensen](https://rubytalk.org/u/Rando_Christensen)\
**Post date:** [21 July 2004 05:33 UTC](https://rubytalk.org/t/compiling-ruby-code/12668/10 "2004-07-21T05:33:16Z")

</div>

Dave Baldwin wrote:

> You may even be able to omit the interpreter as Ruby 1.6 is installed as standard (I may be wrong, but I don't think it is part of the developer tools).

This is correct. 1.6 ships with panther and up, 1.8 will be in tiger.

> **···**
>
> --  
> Rando Christensen  
> \<eyez@illuzionz.org\>

---

<div class="post-metadata">

**Author:** ![Lothar\_Scholz2](https://avatars.discourse-cdn.com/v4/letter/l/f14d63/32.png) [@Lothar\_Scholz2](https://rubytalk.org/u/Lothar_Scholz2)\
**Post date:** [21 July 2004 05:14 UTC](https://rubytalk.org/t/compiling-ruby-code/12668/11 "2004-07-21T05:14:29Z")

</div>

Hello Lothar,

> Hello Erik,

> > The problem with Linux is how to determine which dependencies  
> > are to be distributed in the binary. On my system (RH8), Ruby  
> > (the core and \*.so) needs at least the following files (both  
> > direct and indirect):

> > /lib/ld-linux.so.2  
> > /lib/libNoVersion.so.1  
> > /lib/libc.so.6  
> > /lib/libcrypt.so.1  
> > /lib/libdl.so.2  
> > /lib/libgcc\_s.so.1  
> > /lib/libm.so.6  
> > /lib/libnss\_files.so.2  
> > /usr/lib/libgdbm.so.2  
> > /usr/lib/libncurses.so.5  
> > /usr/lib/libreadline.so.4

> > Can I assume that these are available on all modern  
> > distributions, so I only need to distribute /usr/bin/ruby and  
> > /usr/lib/libruby.so.1.6 (besides the "application-specific"  
> > stripped rubylib tree)? What about the versions? Is 1.8 more  
> > complex? How can I test on several distributions,  
> > cross-distribution? Anybody?

> Read Chapter 3 from

> [http://www.linuxbase.org/modules.php?name=specrev&url=http://www.linuxbase.org/spec/booksets/LSB-Core/LSB-Core.html](http://www.linuxbase.org/modules.php?name=specrev&url=http://www.linuxbase.org/spec/booksets/LSB-Core/LSB-Core.html)

Sorry hit the send button to quickly.  
/lib/ld-linux.so.2 is AFAIK always absolutely addressed for security  
reasons so you can't change it with your own LD\_LIBRARY\_PATH accessible lib.  
And never bundle libgdbm.so.2/libreadline.so.4 without an explicit  
request from the user. They are GPL not LGPL.

> **···**
>
> --  
> Best regards, emailto: scholz at scriptolutions dot com  
> Lothar Scholz [http://www.ruby-ide.com](http://www.ruby-ide.com)  
> CTO Scriptolutions Ruby, PHP, Python IDE 's
