Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pip.vcs.git should use --work-tree instead of implicit $CWD #1130

Closed
jkbrzt opened this issue Aug 12, 2013 · 4 comments · Fixed by #4666
Closed

pip.vcs.git should use --work-tree instead of implicit $CWD #1130

jkbrzt opened this issue Aug 12, 2013 · 4 comments · Fixed by #4666
Labels
auto-locked Outdated issues that have been locked by automation C: vcs pip's interaction with version control systems like git, svn and bzr type: bug A confirmed bug or unintended behavior

Comments

@jkbrzt
Copy link

jkbrzt commented Aug 12, 2013

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.

@thedrow
Copy link

thedrow commented Sep 2, 2013

Could you provide a test case that demonstrate where pip fails exactly?

@jkbrzt
Copy link
Author

jkbrzt commented Sep 2, 2013

Setup:

$ mkvirtualenv pip-test
$ pip install -e git+git@github.com: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.

@speijnik
Copy link

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).

@cjerdonek
Copy link
Member

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.)

cjerdonek added a commit to cjerdonek/pip that referenced this issue Oct 2, 2017
xavfernandez added a commit that referenced this issue Oct 3, 2017
Address issue #1130 (GIT_DIR and GIT_WORK_TREE).
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 3, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation C: vcs pip's interaction with version control systems like git, svn and bzr type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants