I think the 5 sets of files or folder the Rails 3's Bundler create are:
- Gemfile
- Gemfile.lock
- .bundle/config
- vendor/bundle
- vendor/cache
Is there any more? For each of them, should they be added to the repository? Gemfile
and Gemfile.lock
, I think so, because that's what let everybody use the same version of gems. For .bundle/config
, I think for Development, we probably should add it, because it says "Don't use shared gems" (I think this mean system gems)... etc. I read one doc that says if it is deployment, then use .gitignore
to ignore this file, because it can be different on each deployment machine (how?)... so does that mean only on the deployment machine, use a local .gitignore
to ignore it, while in development, don't ignore it?
What about for vendor/bundle
files? They can contain compiled binaries, so if they are added to the project by a Macbook developer, will another developer using Linux be affected by it? (Or when the project is cloned to the deployment server which uses Linux).
What about vendor/cache
? It contains all the .gem
files. Can they contain any binary files? Or are they always for the user to do a bundle install --local
, and they all contain only text files, so they w开发者_StackOverflow社区ill generate the appropriate binary files, if any, on the gem directory, so whether adding this folder to the project is optional, although if we run bundle package
to generate this folder, the intention is probably so that everybody create the gems using this folder instead of pulling it from rubygems.org?
Yes, the Gemfile and Gemfile.lock should both be under revision control. Not sure about the others (I don't have them on my system).
Gemfile indicates which gems are used in your project (and possibly which versions), while the Gemfile.lock indicates which versions you are currently using. By having both in Git, you'll ensure all project developers are using the same gem versions, which will prevent many issues like "it works on my machine, I don't know why it doesn't work on yours" (because 2 developers are using different version of the same gem, which might have bugs).
Gemfile and Gemfile.lock should be part of your source control. It'll allow other developers and yourself easily intall the required gems for your project on other systems.
.bundle/config should be different for each machine and shouldn't be part of source control.
vendor/bundle: should not be part of your source control as it's gems required to run your app. As you noted in your question about the binaries in the folder. They should be recompiled for each system they're run on.
vendor/cache: Don't add this to source control. It's a cache file that could be used to install missing gems faster if they're already present here.
Note that you can choose the location of the bundle and cache directories by editing the .bundle/config and then they won't be install in your app directory if you don't want them there.
精彩评论