# Multiple Versions of Ruby on same machine

**URL:** <https://www.ruby-forum.com/t/multiple-versions-of-ruby-on-same-machine/80908>\
**Category:** Ruby\
**Created:** [January 1, 2007, 8:35pm UTC](https://www.ruby-forum.com/t/multiple-versions-of-ruby-on-same-machine/80908 "2007-01-01T20:35:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![robertjames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9c0ed/32.png) [@robertjames](https://www.ruby-forum.com/u/robertjames)\
**Post date:** [January 1, 2007, 8:35pm UTC](https://www.ruby-forum.com/t/multiple-versions-of-ruby-on-same-machine/80908/1 "2007-01-01T20:35:57Z")

</div>

I’d like to include a complete version of Ruby, including all the  
necessary libs, in the source tree for our internal app. That will  
allow our unit tests/QA procedure/app deployment scripts to take  
responsibility for upgrades to Ruby as well.

To do this, I of course need to include /usr/lib/ruby/\* and  
/usr/bin/ruby. And to set the PATH to use our local Ruby.

But it seems that I need to do more:  
$ irb  
irb(main):001:0\> $:  
=\> ["/usr/lib/ruby/site\_ruby/1.8",  
“/usr/lib/ruby/site\_ruby/1.8/i386-linux”, “/usr/lib/ruby/site\_ruby”,  
“/usr/lib/site\_ruby/1.8”, “/usr/lib/site\_ruby/1.8/i386-linux”,  
“/usr/lib/site\_ruby”, “/usr/lib/ruby/1.8”,  
“/usr/lib/ruby/1.8/i386-linux”, “.”]

Where are those paths located? strings ruby didn’t turn them up. I  
need to be able to tell it to use the app’s private ruby installation.

In general, has anyone done anything like this? What was their  
experience? How would you recommend going about doing this?

---

<div class="post-metadata">

**Author:** ![robertjames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9c0ed/32.png) [@robertjames](https://www.ruby-forum.com/u/robertjames)\
**Post date:** [January 1, 2007, 8:52pm UTC](https://www.ruby-forum.com/t/multiple-versions-of-ruby-on-same-machine/80908/2 "2007-01-01T20:52:55Z")

</div>

Robert J. wrote:

> I’d like to include a complete version of Ruby, including all the  
> necessary libs, in the source tree for our internal app. That will  
> allow our unit tests/QA procedure/app deployment scripts to take  
> responsibility for upgrades to Ruby as well.
> 
> To do this, I of course need to include /usr/lib/ruby/\* and  
> /usr/bin/ruby. And to set the PATH to use our local Ruby.
> 
> But it seems that I need to do more:  
> $ irb  
> irb(main):001:0\> $:  
> =\> ["/usr/lib/ruby/site\_ruby/1.8",  
> “/usr/lib/ruby/site\_ruby/1.8/i386-linux”, “/usr/lib/ruby/site\_ruby”,  
> “/usr/lib/site\_ruby/1.8”, “/usr/lib/site\_ruby/1.8/i386-linux”,  
> “/usr/lib/site\_ruby”, “/usr/lib/ruby/1.8”,  
> “/usr/lib/ruby/1.8/i386-linux”, “.”]
> 
> Where are those paths located? strings ruby didn’t turn them up. I  
> need to be able to tell it to use the app’s private ruby installation.
> 
> In general, has anyone done anything like this? What was their  
> experience? How would you recommend going about doing this?

It’s compiled in at build time, I think. Check out ruby config.

I think I’d try building it from source and installing in a custom  
directory for example /opt/myruby. Then when you install it on the  
target machines you put it in the same place.

---

<div class="post-metadata">

**Author:** ![robertjames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9c0ed/32.png) [@robertjames](https://www.ruby-forum.com/u/robertjames)\
**Post date:** [January 1, 2007, 11:58pm UTC](https://www.ruby-forum.com/t/multiple-versions-of-ruby-on-same-machine/80908/3 "2007-01-01T23:58:17Z")

</div>

On 1/1/07, S. Robert J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’d like to include a complete version of Ruby, including all the  
> necessary libs, in the source tree for our internal app.

I’m not sure if this is applicable in your particular situation, but you  
can  
change $: at runtime using the “shift” and “unshift” methods. You  
could modify your Ruby scripts to change $: as the first thing they do,  
so all the paths point to your local version of Ruby.

Wayne

* * *

Wayne V.  
No Bugs Software  
Ruby, C# and Erlang Agile Contract Programming in Silicon Valley

---

<div class="post-metadata">

**Author:** ![robertjames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9c0ed/32.png) [@robertjames](https://www.ruby-forum.com/u/robertjames)\
**Post date:** [January 2, 2007, 12:42am UTC](https://www.ruby-forum.com/t/multiple-versions-of-ruby-on-same-machine/80908/4 "2007-01-02T00:42:22Z")

</div>

On 1/1/07, S. Robert J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> In general, has anyone done anything like this? What was their  
> experience? How would you recommend going about doing this?

I don’t really have any experience with this, but I think multiruby in  
ZenTest does this, and you might be able to use it as a reference.

---

<div class="post-metadata">

**Author:** ![robertjames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9c0ed/32.png) [@robertjames](https://www.ruby-forum.com/u/robertjames)\
**Post date:** [January 2, 2007, 12:18am UTC](https://www.ruby-forum.com/t/multiple-versions-of-ruby-on-same-machine/80908/5 "2007-01-02T00:18:19Z")

</div>

S. Robert J. wrote:

> Where are those paths located? strings ruby didn’t turn them up. I  
> need to be able to tell it to use the app’s private ruby installation.
> 
> In general, has anyone done anything like this? What was their  
> experience? How would you recommend going about doing this?

You can install Ruby anywhere by getting the source code and running  
something like:

./configure --prefix=/your/favorite/directory  
make  
make install

Then, you should make sure that the right version is used when running  
your project. Make sure that:

- this install of ruby is in the $PATH
- your scripts include the full path to your ruby executable in the  
#!.. line

Is that what you were looking for ?

```
Vince
```

---

<div class="post-metadata">

**Author:** ![robertjames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9c0ed/32.png) [@robertjames](https://www.ruby-forum.com/u/robertjames)\
**Post date:** [January 2, 2007, 2:04am UTC](https://www.ruby-forum.com/t/multiple-versions-of-ruby-on-same-machine/80908/6 "2007-01-02T02:04:36Z")

</div>

Is there a similar method to use a different Ruby version with Rails?

---

<div class="post-metadata">

**Author:** ![robertjames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9c0ed/32.png) [@robertjames](https://www.ruby-forum.com/u/robertjames)\
**Post date:** [January 2, 2007, 6:06am UTC](https://www.ruby-forum.com/t/multiple-versions-of-ruby-on-same-machine/80908/7 "2007-01-02T06:06:58Z")

</div>

matt [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is there a similar method to use a different Ruby version with Rails?

i don’t know how but i’m sure it is because i’ve only Rails under jRuby  
which has it’s own ruby install.
