# Copying a Ruby installation

**URL:** <https://www.ruby-forum.com/t/copying-a-ruby-installation/168242>\
**Category:** Ruby\
**Created:** [May 18, 2009, 5:22pm UTC](https://www.ruby-forum.com/t/copying-a-ruby-installation/168242 "2009-05-18T17:22:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![muralikrishna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8e7dd6/32.png) [@muralikrishna](https://www.ruby-forum.com/u/muralikrishna)\
**Post date:** [May 18, 2009, 5:22pm UTC](https://www.ruby-forum.com/t/copying-a-ruby-installation/168242/1 "2009-05-18T17:22:19Z")

</div>

I am trying to copy an entire ruby installation

So, say for e.g. I installed ruby under /usr/ruby

e.g. cp -R /usr/ruby /usr1; rm -rf /usr/ruby

I want to be able to copy it to some other directory say /usr1/ruby and  
run (Let us also imagine that /usr/ruby has been deleted). My use case  
is that of cloning a ruby repo across the network. So the user that  
clones the ruby installation cannot see the original installation under  
/usr/ruby

So, I did the copy (clone) and it was unable to find things like  
fileutils initially. Then, I set the RUBYLIB and it again failed in  
yaml.rb saying

ruby/lib/ruby/1.9.1/yaml.rb:9:in `require’: no such file to load –  
stringio (LoadError)

What other variables do I have to set to make a copied/cloned ruby  
installation work?

---

<div class="post-metadata">

**Author:** ![muralikrishna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8e7dd6/32.png) [@muralikrishna](https://www.ruby-forum.com/u/muralikrishna)\
**Post date:** [May 20, 2009, 2:45pm UTC](https://www.ruby-forum.com/t/copying-a-ruby-installation/168242/2 "2009-05-20T14:45:33Z")

</div>

> e.g. cp -R /usr/ruby /usr1; rm -rf /usr/ruby

Unfortunately with linux installed ruby, some things (like the #! first  
line of installed binaries) are hard coded to the location of ruby when  
they were first installed.

If that’s not a hinderance, though, _maybe_ you could get by with  
changing rbconfig.rb  
Maybe.

On windows interestingly this isn’t a problem–it can’t run scripts  
anyway so it always (for better or worse) just runs the first ruby it  
finds in the path. So you can move your ruby dirs in windows all right.

-=r

---

<div class="post-metadata">

**Author:** ![muralikrishna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8e7dd6/32.png) [@muralikrishna](https://www.ruby-forum.com/u/muralikrishna)\
**Post date:** [May 20, 2009, 3:00pm UTC](https://www.ruby-forum.com/t/copying-a-ruby-installation/168242/3 "2009-05-20T15:00:57Z")

</div>

Murali Somanchy wrote:

> I want to be able to copy it to some other directory say /usr1/ruby and  
> run (Let us also imagine that /usr/ruby has been deleted).

This may or may not work. Ruby remembers a lot of things about how it  
was built and where it was installed: see

$ ruby -rrbconfig -rpp -e ‘pp Config::CONFIG’

Have a look in your rbconfig.rb, which may be somewhere like  
/usr/lib/ruby/1.8/i486-linux/rbconfig.rb

Many of the constants in this file are defined relative to where  
rbconfig.rb itself exists, so they will be OK, but others may not.

Tools like rake use ‘bindir’ + ‘ruby\_install\_name’ to locate the ruby  
interpreter itself (to reinvoke it)

It is almost certainly going to be safer to recompile ruby to install  
under /usr1/ruby, and then distribute that. Use:

```
./configure --prefix=/usr1/ruby
```
