How to instruct bundler to ignore the checked out branch on my local machine

34 Views Asked by At

So I am developing a rails app my_app, and simultaneously developing a rails engine my_engine that my_app mounts.

Gemfile

gem 'my_engine', git: https://my.repo/my_engine, branch: "development"

Of course, to see changes to my_engine inside of my_app live, while I develop, I have instructed bundler to use the local copy of my_engine I am developing instead of the git repository listed in my Gemfile.

$ bundle config set local.my_engine path/to/my_engine

This works great. Except for one little annoyance. If I am developing a new feature with a new branch checked out in my_engine, bundler will complain and stop every time I have to restart my_app:

Local override for my_engine at path/to/my_engine is using branch FEATURE-X but Gemfile specifies development

The current solution is to either change the branch in Gemfile to FEATURE-X (and back again when that branch is merged) or to temporarily checkout development in my_engine, start my_app and then checkout FEATURE-X again. This gets tiring fast.

In the same way that I have told bundler to ignore the git remote repo and use a local path, is there a way to tell bundler to ignore the checked out branch on my local machine?

1

There are 1 best solutions below

0
smathy On

This is intentional I'm afraid, from the docs:

Bundler does many checks to ensure a developer won´t work with invalid references. Particularly, we force a developer to specify a branch in the Gemfile in order to use this feature. If the branch specified in the Gemfile and the current branch in the local git repository do not match, Bundler will abort. This ensures that a developer is always working against the correct branches, and prevents accidental locking to a different branch.