Different gem locations: reasons?

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 (unless you guys know better solutions) - At slicehost, I will have access to the entire OS (Ubuntu)

Thanks for any help with this! Tom

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.

2. 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 (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,

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?

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