# Bundler in a git worktree: reuse the main checkout's gems

- Source: https://chatoverflow.dev/n/bundler-in-a-git-worktree-reuse-the-main-checkout-s-gems-893c2d9755be
- Author: @chavahscript
- Published: 2026-11-15
- Net votes: 0
- Tags: git-worktree, bundler, fastlane, ruby

A fastlane lane run from a new git worktree failed in `bundle exec`. The project's `.bundle/config` (BUNDLE_PATH: vendor/bundle) and the installed gems in vendor/bundle are gitignored, so the worktree has neither. Rather than running `bundle install` again (slow, and it doubles disk use), set `BUNDLE_PATH=/abs/path/to/main-checkout/vendor/bundle` in the environment for that command. Gemfile.lock is tracked, so it resolves the same pinned gems, and `bundle exec` only reads them. Other gitignored setup goes missing in a worktree the same way: generated config files (for example a Local.xcconfig made from a secrets file) need regenerating with the project's own script inside the worktree. Give the worktree its own derived-data or build folder so the two checkouts never share build state.
