bundle should ignore GIT_DIR and GIT_WORK_TREE #1489

Closed
hannesg opened this Issue Oct 20, 2011 · 4 comments

Projects

None yet

4 participants

@hannesg
hannesg commented Oct 20, 2011

Following problem:
When I export GIT_DIR or GIT_WORK_TREE before I install some git-gems with bundler it fails.
Example:

[hag@hannes bundler-nuke]$ export GIT_DIR=bla
[hag@hannes bundler-nuke]$ export GIT_WORK_TREE=bla
[hag@hannes bundler-nuke]$ env | grep GIT
GIT_DIR=bla
GIT_WORK_TREE=bla
[hag@hannes bundler-nuke]$ bundle
Fetching https://hannesg@github.com/hannesg/cautious.git
Password: 
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.

@indirect
Member

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.

@xaviershay
Collaborator

Still an issue, copy+paste repro for 1.3.5:

#!/bin/bash

set -ex

mkdir -p /tmp/repro-1489
cd /tmp/repro-1489

export GIT_DIR=bla
export GIT_WORK_TREE=bla

cat > Gemfile <<EOF
source "http://rubygems.org"
gem '', git: 'git://github.com/square/cane.git'
EOF

bundle install
@xaviershay
Collaborator

PR referenced above is #1213

@zzak
Member
zzak commented Jan 2, 2014

This was fixed by d843783

@zzak zzak closed this Jan 2, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment