Search code examples
rubygitbundlergitignore

Should `.bundle` directory be added to CVS?


Recently I moved some of my Ruby project dependencies to development group to not to install them on production environments (like rubocop)

And in those projects I see that there is new file .bundle/config with content like this:

---
BUNDLE_WITH: "development"

Or

---
BUNDLE_WITHOUT: "development"

I think I can safely add this file (and .bundle) folder to .gitignore, but to be sure - is there any best practice for that?

Could not find any useful info on $PROJECT_ROOT/.bundle directory


Solution

  • TL;DR

    Don't store the .bundle directory in source. It's intended to be a local cache of certain bundler settings and flags, rather than something shared between all project contributors.

    Analysis

    There are some arguments for and against storing your Gemfile.lock in source control, but the contents of the .bundle directory are not intended to be shared across multiple users/machines within a project. The only potential use case for tracking .bundle/config is to remember certain flags across runs in a production or testing branch, but that behavior is deprecated anyway.

    Pragmatically, storing the .bundle directory may lead to unintended flag usage by your fellow developers. This is likely to lead to unnecessary debugging efforts, and potentially-surprising behavior for project contributors. A Rake task or setup/deployment script is a better option for handling Bundler flags, especially as this behavior is deprecated and is scheduled to go away in Bundler 3.