It seems that on development machines (like on the Macbook), if we use bundle install --deployment
, all the gems will be installed into the vendor/bundle
folder and it just use more disk space if we have multiple Rails 3 projects (some project just for testing Rails 3). If it is not --deployment
, then the gems will be in the "generic" folder instead of inside the project folder, and so can be shared across projects. Is this true?
Another thing is, do we need to add all files under vendor/bundle
to our repository and push it? It seems that if we do it, we just jam up the repo, because if we don't, all the appropriate gems will be installed by bundle install
using all the gems specified in Gemfile.lock
anyway. (The Gemfile.lock
is a small file in the repo). Is this true too?
When you use the --deployment
flag, Bundler makes sure that every gem you need is vendored i.e. they are copied to a predetermined place your application's folder structure (which happens to be vendor/bundle
in Rails by convention) This is good for two things.
First if you have limited permissions that prevent you from installing gems in your deployment machine, then let you have all the gems needed within your app.
Second, if you want to hack away at the actual code in the gems, you can do so on your vendored copies without affecting the system gems. The changes you make will only affect the application you're working on.
This vendoring approach used to have another use, that is making sure that you are using the specific version of a gem, and your application would keep working even if the system gems were upgraded to a higher version that would break your app. However, Bundler itself made this use case mostly obsolete, as it automated the installation and referencing of specific versions of gems.
And yes, vendoring would bloat your app's code. Gemfile.lock
is just a list of the required gems. If you vendor your gems, they get copied into your app with all their might.
So, I recommend you don't vendor your gems (that also means don't use the --deployment
flag) unless you have one of the reasons above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With