# Relocatable Ruby executable

**URL:** <https://rubytalk.org/t/relocatable-ruby-executable/24735>\
**Category:** ruby-talk\
**Created:** [8 February 2006 16:33 UTC](https://rubytalk.org/t/relocatable-ruby-executable/24735 "2006-02-08T16:33:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Asfand\_Yar\_Qazi4](https://avatars.discourse-cdn.com/v4/letter/a/7feea3/32.png) [@Asfand\_Yar\_Qazi4](https://rubytalk.org/u/Asfand_Yar_Qazi4)\
**Post date:** [8 February 2006 16:33 UTC](https://rubytalk.org/t/relocatable-ruby-executable/24735/1 "2006-02-08T16:33:22Z")

</div>

Hi,

How can I create a relocatable Ruby executable? Meaning, that I can distribute a copy of it along with the modules I need with a binary app I am embedding Ruby into. I'm considering both actually programatically embedding Ruby into my app using libruby.a or whatever, as well as making my app an extension library run by the Ruby executable - if you could give details of both, I'd be grateful.

Thanks

> **···**
>
> --  
> To reply, take of all ZIGs !!

---

<div class="post-metadata">

**Author:** ![Joel\_VanderWerf1](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@Joel\_VanderWerf1](https://rubytalk.org/u/Joel_VanderWerf1)\
**Post date:** [8 February 2006 18:53 UTC](https://rubytalk.org/t/relocatable-ruby-executable/24735/2 "2006-02-08T18:53:32Z")

</div>

Asfand Yar Qazi wrote:

> Hi,
> 
> How can I create a relocatable Ruby executable? Meaning, that I can  
> distribute a copy of it along with the modules I need with a binary app  
> I am embedding Ruby into. I'm considering both actually programatically  
> embedding Ruby into my app using libruby.a or whatever, as well as  
> making my app an extension library run by the Ruby executable - if you  
> could give details of both, I'd be grateful.
> 
> Thanks

Are you aware of rubyscript2exe? It packages the interpreter + libraries  
you require + your main script file. I've been very happy with it.

[http://www.erikveen.dds.nl/rubyscript2exe/index.html](http://www.erikveen.dds.nl/rubyscript2exe/index.html)

This is for the ruby extension approach, but not the embedding approach.

> **···**
>
> --  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

---

<div class="post-metadata">

**Author:** ![David\_Vallner](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@David\_Vallner](https://rubytalk.org/u/David_Vallner)\
**Post date:** [8 February 2006 21:23 UTC](https://rubytalk.org/t/relocatable-ruby-executable/24735/3 "2006-02-08T21:23:57Z")

</div>

Dňa Streda 08 Február 2006 17:33 Asfand Yar Qazi napísal:

> Hi,
> 
> How can I create a relocatable Ruby executable? Meaning, that I can  
> distribute a copy of it along with the modules I need with a binary app I  
> am embedding Ruby into. I'm considering both actually programatically  
> embedding Ruby into my app using libruby.a or whatever, as well as making  
> my app an extension library run by the Ruby executable - if you could give  
> details of both, I'd be grateful.
> 
> Thanks

I -think- on Windows the ruby interpreter semiautomagically sets up the paths  
it needs relative to the path where ruby.exe that was run is located, so if  
you can go without the aesthetics and compactness of rubyscript2exe, you  
should be able to safely get away with distributing your ruby directory along  
in the application's distribution somewhere.

David Vallner

---

<div class="post-metadata">

**Author:** ![Asfand\_Yar\_Qazi4](https://avatars.discourse-cdn.com/v4/letter/a/7feea3/32.png) [@Asfand\_Yar\_Qazi4](https://rubytalk.org/u/Asfand_Yar_Qazi4)\
**Post date:** [8 February 2006 21:58 UTC](https://rubytalk.org/t/relocatable-ruby-executable/24735/4 "2006-02-08T21:58:23Z")

</div>

David Vallner wrote:

> Dňa Streda 08 Február 2006 17:33 Asfand Yar Qazi napísal:
> 
> > Hi,
> > 
> > How can I create a relocatable Ruby executable? Meaning, that I can  
> > distribute a copy of it along with the modules I need with a binary app I  
> > am embedding Ruby into. I'm considering both actually programatically  
> > embedding Ruby into my app using libruby.a or whatever, as well as making  
> > my app an extension library run by the Ruby executable - if you could give  
> > details of both, I'd be grateful.
> > 
> > Thanks
> 
> I -think- on Windows the ruby interpreter semiautomagically sets up the paths it needs relative to the path where ruby.exe that was run is located, so if you can go without the aesthetics and compactness of rubyscript2exe, you should be able to safely get away with distributing your ruby directory along in the application's distribution somewhere.
> 
> David Vallner

I don't think rubyscript2exe is feasible for a game - think something like Quake 3 here. But I could be wrong. I would rather have more control over the files I distribute, that way I can create patches that replace small files easily - rubyscript2exe I assume bundles everything into a single file that is unpacked at runtime.

I'll have a look at it though...

But what about when embedding Ruby in my app? How do I handle module paths then?

Thanks

> **···**
>
> --  
> To reply, take of all ZIGs !!

---

<div class="post-metadata">

**Author:** ![Matt\_Mower](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@Matt\_Mower](https://rubytalk.org/u/Matt_Mower)\
**Post date:** [9 February 2006 09:46 UTC](https://rubytalk.org/t/relocatable-ruby-executable/24735/5 "2006-02-09T09:46:43Z")

</div>

After initializing the interpreter you can use rb\_eval\_string() to  
execute arbitrary Ruby statements and, for example, setup your library  
path by executing (from memory):

rb\_eval\_string( "$:.clear" );  
rb\_eval\_string( "$: \<\< "my library path" );

Regards,

Matt

> **···**
>
> On 08/02/06, Asfand Yar Qazi \<ayZIG0106@qazizig.f2szig.com\> wrote:
> 
> > But what about when embedding Ruby in my app? How do I handle module paths then?
> 
> --  
> Matt Mower :: [http://matt.blogs.it/](http://matt.blogs.it/)

---

<div class="post-metadata">

**Author:** ![Asfand\_Yar\_Qazi4](https://avatars.discourse-cdn.com/v4/letter/a/7feea3/32.png) [@Asfand\_Yar\_Qazi4](https://rubytalk.org/u/Asfand_Yar_Qazi4)\
**Post date:** [9 February 2006 13:33 UTC](https://rubytalk.org/t/relocatable-ruby-executable/24735/6 "2006-02-09T13:33:23Z")

</div>

Matt Mower wrote:

> **···**
>
> > On 08/02/06, Asfand Yar Qazi \<ayZIG0106@qazizig.f2szig.com\> wrote:
> > 
> > > But what about when embedding Ruby in my app? How do I handle module paths then?
> > 
> > After initializing the interpreter you can use rb\_eval\_string() to  
> > execute arbitrary Ruby statements and, for example, setup your library  
> > path by executing (from memory):
> > 
> > rb\_eval\_string( "$:.clear" );  
> > rb\_eval\_string( "$: \<\< "my library path" );
> > 
> > Regards,
> > 
> > Matt
> > 
> > --  
> > Matt Mower :: [http://matt.blogs.it/](http://matt.blogs.it/)
> 
> Ah....
> 
> --  
> To reply, take of all ZIGs !!
