# Ruby gems in lib - spare tire principle

**URL:** <https://www.ruby-forum.com/t/ruby-gems-in-lib-spare-tire-principle/188338>\
**Category:** Ruby\
**Created:** [May 10, 2010, 2:46pm UTC](https://www.ruby-forum.com/t/ruby-gems-in-lib-spare-tire-principle/188338 "2010-05-10T14:46:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fregas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/258eb7/32.png) [@Fregas](https://www.ruby-forum.com/u/Fregas)\
**Post date:** [May 10, 2010, 2:46pm UTC](https://www.ruby-forum.com/t/ruby-gems-in-lib-spare-tire-principle/188338/1 "2010-05-10T14:46:06Z")

</div>

Hi,

I’m working on a console ruby application (not rails!) I will be  
installing this application on several machines. I was wondering if  
there is a way i can build it so i dont have to install the gems i’m  
using for the app on each machine. I’d like to be able to just copy  
the directory to each machine and run it. Ideally, i’d like to put the  
gems in the lib folder or something and reference them from there, so  
i don’t have to even install them on my dev machine. Is there a way to  
do this?

In .net, we call this the “spare tire” principle.

thanks, Craig

---

<div class="post-metadata">

**Author:** ![Fregas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/258eb7/32.png) [@Fregas](https://www.ruby-forum.com/u/Fregas)\
**Post date:** [May 10, 2010, 3:00pm UTC](https://www.ruby-forum.com/t/ruby-gems-in-lib-spare-tire-principle/188338/2 "2010-05-10T15:00:09Z")

</div>

On Mon, May 10, 2010 at 8:45 PM, Fregas [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m working on a console ruby application (not rails!) I will be  
> installing this application on several machines. I was wondering if  
> there is a way i can build it so i dont have to install the gems i’m  
> using for the app on each machine. I’d like to be able to just copy  
> the directory to each machine and run it. Ideally, i’d like to put the  
> gems in the lib folder or something and reference them from there, so  
> i don’t have to even install them on my dev machine. Is there a way to  
> do this? In .net, we call this the “spare tire” principle.

if your app is simple, you can place it together w all the gems in  
one folder.

best regards -botp

---

<div class="post-metadata">

**Author:** ![Fregas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/258eb7/32.png) [@Fregas](https://www.ruby-forum.com/u/Fregas)\
**Post date:** [May 10, 2010, 6:40pm UTC](https://www.ruby-forum.com/t/ruby-gems-in-lib-spare-tire-principle/188338/3 "2010-05-10T18:40:54Z")

</div>

On May 10, 5:40 am, Fregas [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> In .net, we call this the “spare tire” principle.
> 
> thanks, Craig

Ruby Gem “OCRA” lets you “compile” your ruby code into an EXE file  
that you can distribute to others,  
without requiring that the users have Ruby installed on their PCs.

To install ocra:

gem install ocra

This should provide you with an easy way to deploy your program to  
several PC systems.

---

<div class="post-metadata">

**Author:** ![Fregas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/258eb7/32.png) [@Fregas](https://www.ruby-forum.com/u/Fregas)\
**Post date:** [May 10, 2010, 9:02pm UTC](https://www.ruby-forum.com/t/ruby-gems-in-lib-spare-tire-principle/188338/4 "2010-05-10T21:02:01Z")

</div>

On May 10, 8:45 am, Fregas [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> In .net, we call this the “spare tire” principle.

Something like Capistrano might be easier.

---

<div class="post-metadata">

**Author:** ![Fregas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/258eb7/32.png) [@Fregas](https://www.ruby-forum.com/u/Fregas)\
**Post date:** [May 11, 2010, 4:10pm UTC](https://www.ruby-forum.com/t/ruby-gems-in-lib-spare-tire-principle/188338/5 "2010-05-11T16:10:36Z")

</div>

On May 10, 6:40 am, Fregas [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Ideally, i’d like to put the  
> gems in the lib folder or something and reference them from there, so  
> i don’t have to even install them on my dev machine. Is there a way to  
> do this?

1. Create “lib/gems” folder.
2. In that folder, run “gem unpack gemname1 gemname2 …”  
 → You will get new folders for each gem
3. In the main file for your code, put  
Dir.chdir( File.dirname( **FILE** ) )  
$:.unshift( _Dir['lib/gems/_/lib’] )

Ta-da!

---

<div class="post-metadata">

**Author:** ![Fregas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/258eb7/32.png) [@Fregas](https://www.ruby-forum.com/u/Fregas)\
**Post date:** [May 11, 2010, 12:35am UTC](https://www.ruby-forum.com/t/ruby-gems-in-lib-spare-tire-principle/188338/6 "2010-05-11T00:35:05Z")

</div>

Fregas wrote:

> I’m working on a console ruby application (not rails!) I will be  
> installing this application on several machines. I was wondering if  
> there is a way i can build it so i dont have to install the gems i’m  
> using for the app on each machine. I’d like to be able to just copy  
> the directory to each machine and run it. Ideally, i’d like to put the  
> gems in the lib folder or something and reference them from there, so  
> i don’t have to even install them on my dev machine. Is there a way to  
> do this?

That is exactly what crown is for:

> **[GitHub - vjoel/crown: Gather gem lib and bin files under one directory for...](https://github.com/vjoel/crown)**
>
> Gather gem lib and bin files under one directory for fast loading and predictable behavior. - GitHub - vjoel/crown: Gather gem lib and bin files under one directory for fast loading and predictable...

You may also want to check out rip and gem bundler.
