When I export GIT_DIR or GIT_WORK_TREE before I install some git-gems with bundler it fails.
[hag@hannes bundler-nuke]$ export GIT_DIR=bla
[hag@hannes bundler-nuke]$ export GIT_WORK_TREE=bla
[hag@hannes bundler-nuke]$ env | grep GIT
[hag@hannes bundler-nuke]$ bundle
remote: Counting objects: 24, done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 24 (delta 6), reused 24 (delta 6)
Unpacking objects: 100% (24/24), done.
fatal: Not a git repository: 'bla'
Git error: command `git rev-parse master` in directory /usr/local/rvm/gems/ruby-1.9.2-p290/cache/bundler/git/cautious-fbb660f0d922632431a445e4b9a93fac438a29e0 has failed.
If this error persists you could try removing the cache directory '/usr/local/rvm/gems/ruby-1.9.2-p290/cache/bundler/git/cautious-fbb660f0d922632431a445e4b9a93fac438a29e0'
However I think, this behavior is not wanted since these variables may be used for something else.
I think bundler should set the --work-tree and --git-dir options to their default values when interacting with its git repos.
Unfortunately, last time we tried to switch to --work-tree and --git-dir, submodules stopped working. There's a pull request you can check to see the issues that came up. It honestly seems like it might just be easier to explicitly clear GIT_DIR and GIT_WORK_TREE when Bundler invokes git in a subshell.
Still an issue, copy+paste repro for 1.3.5:
mkdir -p /tmp/repro-1489
cat > Gemfile <<EOF
gem '', git: 'git://github.com/square/cane.git'
PR referenced above is #1213
This was fixed by d843783