Guides
- RubyGems Basics
- What is a gem?
- Make your own gem
- Gems with Extensions
- Name your gem
- Publishing your gem
- Security Practices
- Managing owners using UI
- Removing a Published gem
- SSL Certificate Update
- Patterns
- Specification Reference
- Command Reference
- RubyGems.org API
- RubyGems.org API V2.0
- RubyGems.org Compact Index API
- RubyGems.org rate limits
- API key scopes
- Run your own gem server
- Setting up multi-factor authentication
- Using multi-factor authentication in command line
- MFA requirement opt in
- Using S3 as gem source
- Default gems and bundled gems
- Resources
- Contributing to RubyGems
- Frequently Asked Questions
- Plugins
- Common Vulnerabilities and Exposures
- Trusted Publishing
- Organizations
- Credits
Bundler
- Bundler in gems
- Gemfiles
- Getting Started
- How to Upgrade to Bundler 2
- How to deploy bundled applications
- How to install gems from git repositories
- How to manage application dependencies with Bundler
- How to manage groups of gems
- How to manage dependencies with Bundler
- How to troubleshoot RubyGems and Bundler TLS/SSL Issues
- How to update gems with Bundler
- How to use Bundler in a single-file Ruby script
- How to use Bundler with Docker
- How to use Bundler with Rails
- How to use Bundler with Ruby
- How to use Bundler with RubyMotion
- How to use Bundler with Sinatra
- How to use git bisect with Bundler
- How to write a Bundler plugin
- Known Plugins
- Recommended Workflow with Version Control
- Ruby Directive
How to use git bisect with Bundler
How to use git bisect
git bisect is a useful debugging tool. For context, git bisect is a git command that can be used to track down the specific commit which a bug was introduced into the codebase.
If you can find a commit where the code works properly and a commit with the offending bug, you don’t have to trace down the buggy commit by hand. The git bisect command, via binary search, will help you find the offending commit. For example, the Git documentation has a handy git bisect guide that shows two ways to use it.
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.
- The
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. Ifbundle installor running the test can cause changes on the file system, which would preventgit checkoutof the next commit to test if they are not reset.
Here’s a minimal example script that runs the rake task spec:
#!/usr/bin/env bash
bundle install
bin/rake spec
status=$?
git reset --hard HEAD
exit $status
See also the discussion at rubygems/bundler#3726.