The Git backend (pip.vcs.git
) relies on the fact that Git uses $CWD
as the repository directory. The problem is that the environment variables $GIT_DIR
/$GIT_WORK_TREE
can be used to overwrite that, and then always the same repository will be queried instead of the one identified in location
.
So instead $CWD
, pip.vcs.git
should always specify --work-tree
.
http://git-scm.com/blog/2010/04/11/environment.html
Alternatively, it could just unset those variables before invoking git
.
Could you provide a test case that demonstrate where pip fails exactly?
Setup:
$ mkvirtualenv pip-test
$ pip install -e [email protected]:jkbr/httpie.git#egg=httpie
Fail:
$ GIT_DIR=/foo pip freeze
Error when trying to get requirement for VCS system Command /usr/local/bin/git config remote.origin.url failed with error code 1 in /Users/jakub/.virtualenvs/pip-test/src/httpie, falling back to uneditable format
Could not determine repository location of ~/.virtualenvs/pip-test/src/httpie
Pygments==1.6
## !! Could not determine repository location
httpie==0.6.0
requests==1.2.3
wsgiref==0.1.2
GIT_DIR
will be set for example in scripts invoked as Git hooks.
I can confirm this problem, same issue here.
A real world example triggering this unwanted behavior is running pip from inside a git repository's post-update hook.
Inside the hook GIT_DIR will be set to '.', which causes pip to operate on that very repository instead of on the repository cloned by pip.
Besides setting --work-tree explicitly, another solution would be unsetting GIT_DIR (and GIT_WORK_TREE).
I posted PR #4666 to address this. (Note that the tests are fine even though the Travis CI icon shows failure. There seems to be flakiness in the Travis CI test runs lately.)
Most helpful comment
I can confirm this problem, same issue here.
A real world example triggering this unwanted behavior is running pip from inside a git repository's post-update hook.
Inside the hook GIT_DIR will be set to '.', which causes pip to operate on that very repository instead of on the repository cloned by pip.
Besides setting --work-tree explicitly, another solution would be unsetting GIT_DIR (and GIT_WORK_TREE).