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

Cache artifacts become corrupted if I terminate with control-c "poetry add ..." while package is being downloaded #6886

Closed
4 tasks done
munro opened this issue Oct 25, 2022 · 5 comments
Labels
status/duplicate Duplicate issues

Comments

@munro
Copy link

munro commented Oct 25, 2022

  • Poetry version: 1.2.2
  • Python version: 3.11.0
  • OS version and name: macOS 12.6
  • pyproject.toml: poetry new ...
  • I am on the latest stable Poetry version, installed using a recommended method.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have consulted the FAQ and blog for any relevant entries or release notes.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

Hello! Whenever I install any poetry package, and hit control-c while a package is being download, that package becomes corrupted in the the cache.

Here I install some package I don't have currently

$ poetry add plotly
Using version ^5.10.0 for plotly

Updating dependencies
Resolving dependencies... (0.5s)

Writing lock file

Package operations: 2 installs, 0 updates, 0 removals

  • Installing tenacity (8.1.0)
    • Installing plotly (5.10.0): Downloading... 4%

Sending Control-C ...

^C%
$

Trying to install the package again

$ poetry add plotly
Using version ^5.10.0 for plotly

Updating dependencies
Resolving dependencies... (0.1s)

Package operations: 1 install, 0 updates, 0 removals

  • Installing plotly (5.10.0): Failed

  RuntimeError

  Hash for plotly (5.10.0) from archive plotly-5.10.0-py2.py3-none-any.whl not found in known hashes (was: sha256:06ad0009cce2d7248642714f5138d54bde97a8f696762fc602fa9eac27ea089c)

  at ~/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/poetry/installation/executor.py:681 in _validate_archive_hash
      677│         archive_hash: str = "sha256:" + file_dep.hash()
      678│         known_hashes = {f["hash"] for f in package.files}
      679│
      680│         if archive_hash not in known_hashes:
    → 681│             raise RuntimeError(
      682│                 f"Hash for {package} from archive {archive.name} not found in"
      683│                 f" known hashes (was: {archive_hash})"
      684│             )
      685│

Clearing the cache seems doesn't seem to work either.

$ poetry cache clear . --all
$ poetry add plotly
Package operations: 1 install, 0 updates, 0 removals

  • Installing plotly (5.10.0): Failed

  RuntimeError

  Hash for plotly (5.10.0) from archive plotly-5.10.0-py2.py3-none-any.whl not found in known hashes (was: sha256:06ad0009cce2d7248642714f5138d54bde97a8f696762fc602fa9eac27ea089c)

  at ~/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/poetry/installation/executor.py:681 in _validate_archive_hash
      677│         archive_hash: str = "sha256:" + file_dep.hash()
      678│         known_hashes = {f["hash"] for f in package.files}
      679│
      680│         if archive_hash not in known_hashes:
    → 681│             raise RuntimeError(
      682│                 f"Hash for {package} from archive {archive.name} not found in"
      683│                 f" known hashes (was: {archive_hash})"
      684│             )
      685│

I have to actually delete the cache directory to fix it

$ poetry cache clear . --all
$ rm -rf ~/Library/Caches/pypoetry/
$ poetry add plotly
Using version ^5.10.0 for plotly

Updating dependencies
Resolving dependencies... Downloading https://files.pythonhosted.org/packages/b5/d7/91fd8911d22e7fac794803095dd192bf1ebd70c7603272085230d915e738/pytz-2022.5-py2.p

Package operations: 1 install, 0 updates, 0 removals

  • Installing plotly (5.10.0): Downloading... 79%
  • Installing plotly (5.10.0)
$

And now the package is installed!

It's kinda a nightmare for me if my internet get interrupted when installing lots of dependencies for an app.

@munro munro added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Oct 25, 2022
@munro
Copy link
Author

munro commented Oct 25, 2022

Here's the -vvv, also I've switched to Python 3.10.8, and the problem still exists :(

$ poetry add -vvv plotly
Loading configuration file /Users/munro/Library/Preferences/pypoetry/config.toml
Creating virtualenv poetry-testtt in /Users/munro/poetry-testtt/.venv
Using virtualenv: /Users/munro/poetry-testtt/.venv
Using version ^5.10.0 for plotly

Updating dependencies
Resolving dependencies...
   1: fact: poetry-testtt is 0.1.0
   1: derived: poetry-testtt
   1: fact: poetry-testtt depends on tqdm (^4.64.1)
   1: fact: poetry-testtt depends on plotly (^5.10.0)
   1: selecting poetry-testtt (0.1.0)
   1: derived: plotly (>=5.10.0,<6.0.0)
   1: derived: tqdm (>=4.64.1,<5.0.0)
   1: fact: plotly (5.10.0) depends on tenacity (>=6.2.0)
   1: selecting plotly (5.10.0)
   1: derived: tenacity (>=6.2.0)
   1: fact: tqdm (4.64.1) depends on colorama (*)
   1: selecting tqdm (4.64.1)
   1: derived: colorama
   1: selecting tenacity (8.1.0)
   1: selecting colorama (0.4.6)
   1: Version solving took 0.043 seconds.
   1: Tried 1 solutions.

Writing lock file

Finding the necessary packages for the current system

Package operations: 3 installs, 0 updates, 0 removalsInstalling tenacity (8.1.0): Pending...
  • Installing tenacity (8.1.0): Installing...
  • Installing tenacity (8.1.0)
  • Installing plotly (5.10.0): Pending...
  • Installing plotly (5.10.0): Failed

  Stack trace:

  6  ~/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/executor.py:261 in _execute_operation
      259260try:
    → 261result = self._do_execute_operation(operation)
      262except EnvCommandError as e:
      263if e.e.returncode == -2:

  5  ~/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/executor.py:334 in _do_execute_operation
      332return 0
      333│ 
    → 334result: int = getattr(self, f"_execute_{method}")(operation)
      335336if result != 0:

  4  ~/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/executor.py:454 in _execute_install
      452453def _execute_install(self, operation: Install | Update) -> int:
    → 454status_code = self._install(operation)
      455456self._save_url_reference(operation)

  3  ~/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/executor.py:488 in _install
      486archive = self._download_link(operation, Link(package.source_url))
      487else:
    → 488archive = self._download(operation)
      489490operation_message = self.get_operation_message(operation)

  2  ~/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/executor.py:647 in _download
      645self._yanked_warnings.append(message)
      646│ 
    → 647return self._download_link(operation, link)
      648649def _download_link(self, operation: Install | Update, link: Link) -> Path:

  1  ~/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/executor.py:668 in _download_link
      666667if package.files:
    → 668archive_hash = self._validate_archive_hash(archive, package)
      669670self._hashes[package.name] = archive_hash

  RuntimeError

  Hash for plotly (5.10.0) from archive plotly-5.10.0-py2.py3-none-any.whl not found in known hashes (was: sha256:309233ffc975e9ca1d75d21829c1c47ed02965985cba67b01d9b61ad162590e8)

  at ~/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/executor.py:681 in _validate_archive_hash
      677archive_hash: str = "sha256:" + file_dep.hash()
      678known_hashes = {f["hash"] for f in package.files}
      679680if archive_hash not in known_hashes:
    → 681raise RuntimeError(
      682f"Hash for {package} from archive {archive.name} not found in"
      683f" known hashes (was: {archive_hash})"
      684│             )
      685│ 

  • Installing tqdm (4.64.1): Pending...
  • Installing tqdm (4.64.1): Installing...
  • Installing tqdm (4.64.1)

@dimbleby
Copy link
Contributor

#6186

@neersighted
Copy link
Member

This is fixed in 1.3; it would be wonderful if you test that version and confirm you can no longer reproduce this, since you are in that 'zone' right now. I'd like to get a 1.3 beta you can install with --pre soon; mostly, none of the core maintainers have had enough time to start that process in the last week or so.

@neersighted neersighted added status/duplicate Duplicate issues and removed kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Oct 25, 2022
@munro
Copy link
Author

munro commented Oct 25, 2022

@neersighted ahh cool, I just installed poetry from branch 1.2 at commit 507f506 and it's fixed 👏 👏 👏

Copy link

github-actions bot commented Mar 1, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status/duplicate Duplicate issues
Projects
None yet
Development

No branches or pull requests

3 participants