# Different gem locations: reasons?

**URL:** <https://www.ruby-forum.com/t/different-gem-locations-reasons/173578>\
**Category:** Rails\
**Created:** [August 11, 2009, 5:25pm UTC](https://www.ruby-forum.com/t/different-gem-locations-reasons/173578 "2009-08-11T17:25:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [August 11, 2009, 5:25pm UTC](https://www.ruby-forum.com/t/different-gem-locations-reasons/173578/1 "2009-08-11T17:25:05Z")

</div>

Hi there,

as far as I know, gems can be stored in 2 folders:

1. /usr/lib/ruby/gems/1.8/gems
2. app/vendor/gems

When I install a gem, it automatically goes into the 1st folder.

My questions are:

- What are the reasons one should store the gems in the 2nd folder  
(app/…)?
- Does it have anything to do with deployment/“portability”? If yes,  
how?
- How should gems be put in there? Any special command or is copy/paste  
OK?
- Do apps automatically find the correct location of the gems? Any  
config to do?
- How are gems in app/vendor/gems updated? Using the normal gem update  
command?

Background info:

- I’m pretty much a n00b
- I plan to deploy my app to [slicehost.com](http://slicehost.com) (unless you guys know better  
solutions)
- At slicehost, I will have access to the entire OS (Ubuntu)

Thanks for any help with this!  
Tom

---

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [August 11, 2009, 5:37pm UTC](https://www.ruby-forum.com/t/different-gem-locations-reasons/173578/2 "2009-08-11T17:37:39Z")

</div>

Tom Ha wrote:

> Hi there,
> 
> as far as I know, gems can be stored in 2 folders:
> 
> 1. /usr/lib/ruby/gems/1.8/gems

These are the gems that are available to the system as a whole.

> 1. app/vendor/gems

These are the gems available to your application.

> When I install a gem, it automatically goes into the 1st folder.

Right. The gem command installs gems for the whole system.

> My questions are:
> 
> - What are the reasons one should store the gems in the 2nd folder  
> (app/…)?
> - Does it have anything to do with deployment/“portability”? If yes,  
> how?

If you store gems in app/vendor, they go with your app. This can be  
useful when you’re deploying in a place where you can’t or don’t want to  
install system-wide gems.

> - How should gems be put in there? Any special command or is copy/paste  
> OK?

There’s a rake task for it – rake gems:unpack or something like that.  
rake -T will tell you what you need to know.

> - Do apps automatically find the correct location of the gems? Any  
> config to do?

Rails will look in both the system gem path and vendor for gems.

> - How are gems in app/vendor/gems updated? Using the normal gem update  
> command?

No, because the gem command doesn’t even know about them.

> Background info:
> 
> - I’m pretty much a n00b
> - I plan to deploy my app to [slicehost.com](http://slicehost.com) (unless you guys know better  
> solutions)

Slicehost is great!

> - At slicehost, I will have access to the entire OS (Ubuntu)

Then you can use either approach.

> Thanks for any help with this!  
> Tom

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [August 11, 2009, 5:48pm UTC](https://www.ruby-forum.com/t/different-gem-locations-reasons/173578/3 "2009-08-11T17:48:42Z")

</div>

Very cool - thanks a lot, Marnen & Fred!

---

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [August 11, 2009, 5:38pm UTC](https://www.ruby-forum.com/t/different-gem-locations-reasons/173578/4 "2009-08-11T17:38:56Z")

</div>

On Aug 11, 4:25 pm, Tom Ha [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> - What are the reasons one should store the gems in the 2nd folder  
> (app/…)?
> - Does it have anything to do with deployment/“portability”? If yes,  
> how?
> - How should gems be put in there? Any special command or is copy/paste  
> OK?
> - Do apps automatically find the correct location of the gems? Any  
> config to do?
> - How are gems in app/vendor/gems updated? Using the normal gem update  
> command?

Well the point behind the vendor-everything approach is that it’s  
really easy to roll things back and forward. If you roll out some new  
code which means that for the first time your app requires gem blah  
you don’t need to remember to update/install that gem because it will  
just happen magically when your source code is checked out. It’s also  
handy if you don’t have the file system permissions to update the  
system gems. There are rake tasks supplied by rails for managing this  
stuff

Fred
