How to git bisect in projects using Bundler
A few things that may not be obvious are needed for
git bisect to work
in a project that uses Bundler.
Gemfile.lockneeds to be in the git repo, so that each commit will load the same dependencies every time.
- Each step during the bisect needs to run
bundle installfirst, so that the correct dependencies are installed and available to be loaded.
- After determining if the commit is good or bad, each step needs to
git reset. If
bundle installor running the test can cause changes on the file system, which would prevent
git checkoutof the next commit to test if they are not reset.
Here’s a minimal example script that runs the rake task
#!/bin/bash bundle install bin/rake spec status=$? git reset --hard HEAD exit $status
See also the discussion at bundler/bundler#3726.