Git 后端 ( pip.vcs.git
) 依赖于 Git 使用$CWD
作为存储库目录的事实。 问题是环境变量$GIT_DIR
/ $GIT_WORK_TREE
可用于覆盖它,然后将始终查询相同的存储库而不是location
标识的存储库。
所以$CWD
, pip.vcs.git
应该总是指定--work-tree
。
http://git-scm.com/blog/2010/04/11/environment.html
或者,它可以在调用git
之前取消设置这些变量。
您能否提供一个测试用例来演示 pip 究竟在哪里失败?
设置:
$ mkvirtualenv pip-test
$ pip install -e [email protected]:jkbr/httpie.git#egg=httpie
失败:
$ 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
将在作为 Git 钩子调用的脚本中设置。
我可以确认这个问题,同样的问题在这里。
触发这种不需要的行为的一个真实示例是从 git 存储库的 post-update 钩子内部运行 pip。
在钩子内部 GIT_DIR 将被设置为“.”,这会导致 pip 在该存储库上运行,而不是在 pip 克隆的存储库上运行。
除了显式设置 --work-tree 之外,另一种解决方案是取消设置 GIT_DIR(和 GIT_WORK_TREE)。
我发布了 PR #4666 来解决这个问题。 (请注意,即使 Travis CI 图标显示失败,测试也很好。最近运行的 Travis CI 测试似乎有些不稳定。)
最有用的评论
我可以确认这个问题,同样的问题在这里。
触发这种不需要的行为的一个真实示例是从 git 存储库的 post-update 钩子内部运行 pip。
在钩子内部 GIT_DIR 将被设置为“.”,这会导致 pip 在该存储库上运行,而不是在 pip 克隆的存储库上运行。
除了显式设置 --work-tree 之外,另一种解决方案是取消设置 GIT_DIR(和 GIT_WORK_TREE)。