-
Notifications
You must be signed in to change notification settings - Fork 3k
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 install -e git+https...
will overwrite existing dirty working copies
#5411
Comments
Hey @altendky! Thanks for filing this issue! Was the behavior in pip 9 the same as pip 10? |
Yes, this behavior seems to exist at least back through pip 7.1.2. I stopped at pip 6.1.1 because it gave another unrelated error. pip 9.0.3altendky@lt:~/t$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 9.4 (stretch)
Release: 9.4
Codename: stretch
altendky@lt:~/t$ python3 -m venv venv
altendky@lt:~/t$ venv/bin/python --version
Python 3.6.5
altendky@lt:~/t$ venv/bin/python -m pip install --upgrade pip==9.*
Requirement already up-to-date: pip==9.* in ./venv/lib/python3.6/site-packages
You are using pip version 9.0.3, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
altendky@lt:~/t$ export PIP_SRC=$PWD/src
altendky@lt:~/t$ venv/bin/pip install -e git+https://github.com/altendky/gitignoreio#egg=gitignoreio
Obtaining gitignoreio from git+https://github.com/altendky/gitignoreio#egg=gitignoreio
Cloning https://github.com/altendky/gitignoreio to ./src/gitignoreio
Collecting click (from gitignoreio)
Cache entry deserialization failed, entry ignored
Using cached https://files.pythonhosted.org/packages/34/c1/8806f99713ddb993c5366c362b2f908f18269f8d792aff1abfd700775a77/click-6.7-py2.py3-none-any.whl
Collecting requests (from gitignoreio)
Cache entry deserialization failed, entry ignored
Using cached https://files.pythonhosted.org/packages/49/df/50aa1999ab9bde74656c2919d9c0c085fd2b3775fd3eca826012bef76d8c/requests-2.18.4-py2.py3-none-any.whl
Collecting urllib3<1.23,>=1.21.1 (from requests->gitignoreio)
Cache entry deserialization failed, entry ignored
Using cached https://files.pythonhosted.org/packages/63/cb/6965947c13a94236f6d4b8223e21beb4d576dc72e8130bd7880f600839b8/urllib3-1.22-py2.py3-none-any.whl
Collecting idna<2.7,>=2.5 (from requests->gitignoreio)
Cache entry deserialization failed, entry ignored
Using cached https://files.pythonhosted.org/packages/27/cc/6dd9a3869f15c2edfab863b992838277279ce92663d334df9ecf5106f5c6/idna-2.6-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests->gitignoreio)
Cache entry deserialization failed, entry ignored
Using cached https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests->gitignoreio)
Cache entry deserialization failed, entry ignored
Using cached https://files.pythonhosted.org/packages/7c/e6/92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5/certifi-2018.4.16-py2.py3-none-any.whl
Installing collected packages: click, urllib3, idna, chardet, certifi, requests, gitignoreio
Running setup.py develop for gitignoreio
Successfully installed certifi-2018.4.16 chardet-3.0.4 click-6.7 gitignoreio idna-2.6 requests-2.18.4 urllib3-1.22
You are using pip version 9.0.3, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
altendky@lt:~/t$ git -C src/gitignoreio/ status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
altendky@lt:~/t$ echo '#blah' >> src/gitignoreio/setup.py
altendky@lt:~/t$ git -C src/gitignoreio/ status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: setup.py
no changes added to commit (use "git add" and/or "git commit -a")
altendky@lt:~/t$ venv/bin/pip install -e git+https://github.com/altendky/gitignoreio#egg=gitignoreio
Obtaining gitignoreio from git+https://github.com/altendky/gitignoreio#egg=gitignoreio
Updating ./src/gitignoreio clone
Requirement already satisfied: click in ./venv/lib/python3.6/site-packages (from gitignoreio)
Requirement already satisfied: requests in ./venv/lib/python3.6/site-packages (from gitignoreio)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in ./venv/lib/python3.6/site-packages (from requests->gitignoreio)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in ./venv/lib/python3.6/site-packages (from requests->gitignoreio)
Requirement already satisfied: certifi>=2017.4.17 in ./venv/lib/python3.6/site-packages (from requests->gitignoreio)
Requirement already satisfied: idna<2.7,>=2.5 in ./venv/lib/python3.6/site-packages (from requests->gitignoreio)
Installing collected packages: gitignoreio
Found existing installation: gitignoreio 0.1.5
Uninstalling gitignoreio-0.1.5:
Successfully uninstalled gitignoreio-0.1.5
Running setup.py develop for gitignoreio
Successfully installed gitignoreio
You are using pip version 9.0.3, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
altendky@lt:~/t$ git -C src/gitignoreio/ status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
altendky@lt:~/t$ pip 8.1.2altendky@lt:~/t$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 9.4 (stretch)
Release: 9.4
Codename: stretch
altendky@lt:~/t$ python3 -m venv venv
altendky@lt:~/t$ venv/bin/python --version
Python 3.6.5
altendky@lt:~/t$ venv/bin/python -m pip install --upgrade pip==8.*
Collecting pip==8.*
Downloading https://files.pythonhosted.org/packages/9c/32/004ce0852e0a127f07f358b715015763273799bd798956fa930814b60f39/pip-8.1.2-py2.py3-none-any.whl (1.2MB)
100% |████████████████████████████████| 1.2MB 1.2MB/s
Installing collected packages: pip
Found existing installation: pip 9.0.3
Uninstalling pip-9.0.3:
Successfully uninstalled pip-9.0.3
Successfully installed pip-8.1.2
You are using pip version 8.1.2, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
altendky@lt:~/t$ export PIP_SRC=$PWD/src
altendky@lt:~/t$ venv/bin/pip install -e git+https://github.com/altendky/gitignoreio#egg=gitignoreio
Obtaining gitignoreio from git+https://github.com/altendky/gitignoreio#egg=gitignoreio
Cloning https://github.com/altendky/gitignoreio to ./src/gitignoreio
Collecting click (from gitignoreio)
Using cached https://files.pythonhosted.org/packages/34/c1/8806f99713ddb993c5366c362b2f908f18269f8d792aff1abfd700775a77/click-6.7-py2.py3-none-any.whl
Collecting requests (from gitignoreio)
Using cached https://files.pythonhosted.org/packages/49/df/50aa1999ab9bde74656c2919d9c0c085fd2b3775fd3eca826012bef76d8c/requests-2.18.4-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests->gitignoreio)
Using cached https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl
Collecting urllib3<1.23,>=1.21.1 (from requests->gitignoreio)
Using cached https://files.pythonhosted.org/packages/63/cb/6965947c13a94236f6d4b8223e21beb4d576dc72e8130bd7880f600839b8/urllib3-1.22-py2.py3-none-any.whl
Collecting idna<2.7,>=2.5 (from requests->gitignoreio)
Using cached https://files.pythonhosted.org/packages/27/cc/6dd9a3869f15c2edfab863b992838277279ce92663d334df9ecf5106f5c6/idna-2.6-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests->gitignoreio)
Using cached https://files.pythonhosted.org/packages/7c/e6/92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5/certifi-2018.4.16-py2.py3-none-any.whl
Installing collected packages: click, chardet, urllib3, idna, certifi, requests, gitignoreio
Running setup.py develop for gitignoreio
Successfully installed certifi-2018.4.16 chardet-3.0.4 click-6.7 gitignoreio idna-2.6 requests-2.18.4 urllib3-1.22
You are using pip version 8.1.2, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
altendky@lt:~/t$ git -C src/gitignoreio/ status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
altendky@lt:~/t$ echo '#blah' >> src/gitignoreio/setup.py
altendky@lt:~/t$ git -C src/gitignoreio/ status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: setup.py
no changes added to commit (use "git add" and/or "git commit -a")
altendky@lt:~/t$ venv/bin/pip install -e git+https://github.com/altendky/gitignoreio#egg=gitignoreio
Obtaining gitignoreio from git+https://github.com/altendky/gitignoreio#egg=gitignoreio
Updating ./src/gitignoreio clone
Requirement already satisfied (use --upgrade to upgrade): click in ./venv/lib/python3.6/site-packages (from gitignoreio)
Requirement already satisfied (use --upgrade to upgrade): requests in ./venv/lib/python3.6/site-packages (from gitignoreio)
Requirement already satisfied (use --upgrade to upgrade): certifi>=2017.4.17 in ./venv/lib/python3.6/site-packages (from requests->gitignoreio)
Requirement already satisfied (use --upgrade to upgrade): idna<2.7,>=2.5 in ./venv/lib/python3.6/site-packages (from requests->gitignoreio)
Requirement already satisfied (use --upgrade to upgrade): chardet<3.1.0,>=3.0.2 in ./venv/lib/python3.6/site-packages (from requests->gitignoreio)
Requirement already satisfied (use --upgrade to upgrade): urllib3<1.23,>=1.21.1 in ./venv/lib/python3.6/site-packages (from requests->gitignoreio)
Installing collected packages: gitignoreio
Running setup.py develop for gitignoreio
Successfully installed gitignoreio-0.1.5
You are using pip version 8.1.2, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
altendky@lt:~/t$ git -C src/gitignoreio/ status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
altendky@lt:~/t$ pip 7.1.2altendky@lt:~/t$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 9.4 (stretch)
Release: 9.4
Codename: stretch
altendky@lt:~/t$ python3 -m venv venv
altendky@lt:~/t$ venv/bin/python --version
Python 3.6.5
altendky@lt:~/t$ venv/bin/python -m pip install --upgrade pip==7.*
Collecting pip==7.*
Downloading https://files.pythonhosted.org/packages/b2/d0/cd115fe345dd6f07ec1c780020a7dfe74966fceeb171e0f20d1d4905b0b7/pip-7.1.2-py2.py3-none-any.whl (1.1MB)
100% |████████████████████████████████| 1.1MB 1.3MB/s
Installing collected packages: pip
Found existing installation: pip 9.0.3
Uninstalling pip-9.0.3:
Successfully uninstalled pip-9.0.3
Successfully installed pip-7.1.2
You are using pip version 7.1.2, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
altendky@lt:~/t$ export PIP_SRC=$PWD/src
altendky@lt:~/t$ venv/bin/pip install -e git+https://github.com/altendky/gitignoreio#egg=gitignoreio
Obtaining gitignoreio from git+https://github.com/altendky/gitignoreio#egg=gitignoreio
Cloning https://github.com/altendky/gitignoreio to ./src/gitignoreio
Collecting click (from gitignoreio)
Using cached https://files.pythonhosted.org/packages/34/c1/8806f99713ddb993c5366c362b2f908f18269f8d792aff1abfd700775a77/click-6.7-py2.py3-none-any.whl
Collecting requests (from gitignoreio)
Using cached https://files.pythonhosted.org/packages/49/df/50aa1999ab9bde74656c2919d9c0c085fd2b3775fd3eca826012bef76d8c/requests-2.18.4-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests->gitignoreio)
Using cached https://files.pythonhosted.org/packages/7c/e6/92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5/certifi-2018.4.16-py2.py3-none-any.whl
Collecting idna<2.7,>=2.5 (from requests->gitignoreio)
Using cached https://files.pythonhosted.org/packages/27/cc/6dd9a3869f15c2edfab863b992838277279ce92663d334df9ecf5106f5c6/idna-2.6-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests->gitignoreio)
Using cached https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl
Collecting urllib3<1.23,>=1.21.1 (from requests->gitignoreio)
Using cached https://files.pythonhosted.org/packages/63/cb/6965947c13a94236f6d4b8223e21beb4d576dc72e8130bd7880f600839b8/urllib3-1.22-py2.py3-none-any.whl
Installing collected packages: click, certifi, idna, chardet, urllib3, requests, gitignoreio
Running setup.py develop for gitignoreio
Successfully installed certifi-2018.4.16 chardet-3.0.4 click-6.7 gitignoreio idna-2.6 requests-2.18.4 urllib3-1.22
You are using pip version 7.1.2, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
altendky@lt:~/t$ git -C src/gitignoreio/ status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
altendky@lt:~/t$ echo '#blah' >> src/gitignoreio/setup.py
altendky@lt:~/t$ git -C src/gitignoreio/ status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: setup.py
no changes added to commit (use "git add" and/or "git commit -a")
altendky@lt:~/t$ venv/bin/pip install -e git+https://github.com/altendky/gitignoreio#egg=gitignoreio
Obtaining gitignoreio from git+https://github.com/altendky/gitignoreio#egg=gitignoreio
Updating ./src/gitignoreio clone
Requirement already satisfied (use --upgrade to upgrade): click in ./venv/lib/python3.6/site-packages (from gitignoreio)
Requirement already satisfied (use --upgrade to upgrade): requests in ./venv/lib/python3.6/site-packages (from gitignoreio)
Requirement already satisfied (use --upgrade to upgrade): certifi>=2017.4.17 in ./venv/lib/python3.6/site-packages (from requests->gitignoreio)
Requirement already satisfied (use --upgrade to upgrade): urllib3<1.23,>=1.21.1 in ./venv/lib/python3.6/site-packages (from requests->gitignoreio)
Requirement already satisfied (use --upgrade to upgrade): idna<2.7,>=2.5 in ./venv/lib/python3.6/site-packages (from requests->gitignoreio)
Requirement already satisfied (use --upgrade to upgrade): chardet<3.1.0,>=3.0.2 in ./venv/lib/python3.6/site-packages (from requests->gitignoreio)
Installing collected packages: gitignoreio
Running setup.py develop for gitignoreio
Successfully installed gitignoreio-0.1.5
You are using pip version 7.1.2, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
altendky@lt:~/t$ git -C src/gitignoreio/ status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
altendky@lt:~/t$ |
Thanks for the thorough information on this @altendky! :) I think the proposed solution in the description is a good way to solve this. |
There may need to be considerations for working directories that are clean but at another revision etc. I'll try to think this over and consider some more scenarios and ways to identify and handle them. |
I think @cjerdonek in the past made a couple of changes in the area of setting up working copy after vcs clone. Maybe he would have some input? |
I'm almost positive this is a duplicate of another issue, but don't have time at the moment to find the issue number. And @piotr-dobrogost, yes, I commented on that earlier issue -- agreeing that a force reset shouldn't happen automatically because people can lose their work. IIRC, the branch should be checked out but not force reset. |
Probably you have in mind issue #647 – pip install -e resets to origin/master |
Yep, thanks. And those PR's I referenced I did work on at some level. But due to a lot of cosmetic refactoring that was happening in pip's code base, those patches got out of sync. I will need to revisit and update them. |
I'd like to work on this issue now that my refactoring of the VCS code is much farther along (thanks to @pradyunsg's help). However, I have a question: If an installation update would result in local changes getting overwritten, is it okay for a behavior change to occur in this case (e.g. erroring out or prompting the user)? Or should backwards compatibility be preserved? One way to preserve backwards compatibility while not losing information would be to automatically "save" any local changes (e.g. in a backup branch) if the tree is dirty, and then warn the user, but that would add more complexity. Are there cases where people might be relying on the |
Is the behavior documented either in the documentation or |
I don't see anything documented. For example, nothing is stated here-- |
To add to my previous comment, pip does already have code to prompt the user with options "(s)witch, (i)gnore, (w)ipe, (b)ackup" if a repository exists at the desired path, but with the wrong URL: pip/src/pip/_internal/vcs/__init__.py Lines 349 to 357 in 9087749
Currently, I don't think this prompt can be bypassed in advance with a command-line flag like a --force option though.
In contrast, it doesn't prompt the user in perhaps the last remaining case of the URL being correct but with the working tree containing changes that would be lost (what this issue is about). However, adding prompt logic is also IMHO the solution that would add the most additional complexity to the code. |
Thanks to @cjerdonek and all the rest of you who have been thinking about this issue. Just thought I'd give it a bump after nearly losing a week's work to it. Seeing a |
Description:
I often have editable installs where the clone is done by pip. It seems that the point of editable installs from a VCS would be to edit them so they should be protected from being carelessly overwritten. Instead, pip overwrites dirty working copies. I would expect to need to
--force
or such to make this happen.What I've run:
https://gist.github.com/altendky/9a8cc1c7bec9f44911a2d904c09eb8b1
The text was updated successfully, but these errors were encountered: