Open sg-s opened 1 year ago
presumably duplicate #6455, #7596, though without a way to repro no-one can do anything with this anyway
please close
it's pretty easy to reproduce:
poetry add git+https://<any private repo>
and @dimbleby while its true that i get the same error, using longer hashes doens't work
I did a poetry add with a private repo that I have on github and this did not reproduce. Without a way to reproduce, no-one but you can do anything with this.
But it's still bound to be a duplicate of those others and can be closed as such.
@dimbleby can i ask what command you used?
i'd love to reproduce your success
exactly as you suggested:
poetry add git+https://ghp_<redacted>@github.com:dimbleby/<redacted>
and did that private git repo dependency have a pyproject.toml file (mine does not)
this is a terrible way to debug and I am dropping out of the conversation.
I recommend that you close this as a duplicate of one of the others.
If you want to share your problem, then set up a repository that does not contain anything secret so that anyone can reproduce whatever it is you are seeing.
I've also run into this problem, I don't have a reproduction, but I can leave a breadcrumb ... it seems to be triggered when a repo that your other private repo depends on is already cloned into Poetry's .venv/src
folder. Deleting the specific repo that your private repo depends on from that folder and adding it again via the normal command seems to run.
Encountered this error today. Poetry 1.3.2, installing from an open source git repo, not using a token. But also on macOS. We were installing into a Docker devcontainer, and we got around the problem by deleting the lock file then rebuilding the container i.e. resolving afresh against an empty cache / env.
@dimbleby continuing our discussion in #8112,
What more info do you need to reproduce? Also, if I wanted to live-debug poetry, would I be able to use pdb?
What more info do you need to reproduce?
... a way to reproduce it!
If you can start from a fresh project and provide steps to show the error, please do so. Even better, wrap that up in a dockerfile to make sure that the same thing will happen for someone else.
poetry is just a regular python program, debug it however you like
I've also run into this problem, I don't have a reproduction, but I can leave a breadcrumb ... it seems to be triggered when a repo that your other private repo depends on is already cloned into Poetry's
.venv/src
folder. Deleting the specific repo that your private repo depends on from that folder and adding it again via the normal command seems to run.
I had a similar issue: poetry lock
always failed with the exception mentioned in this issue whenever a given dependency from a public git repo (pytensor) was in pyproject.toml
. So, in my case, it happened from a public repo (not PRIVATE!). The solution was the one quoted, thanks @timos-flwls : I just deleted .venv/src/pytensor
and the problem disappeared.
Maybe, in my case, an initial poetry install
was interrupted and left a corrupted/broken clone in .venv/src/pytensor
and so all subsequent poetry lock
failed. Clearly, this is hard to reproduce, unless you damage a previously cloned repo on purpose.
Maybe a dulwich
issue more than a poetry
issue?
All in all: remove the guilty repo in .venv/src/
if you stumble into this issue.
I just experienced this error while doing a poetry lock
with a public git repo and, similar to what @emanuele says, in my case it went away after I nuked the venv and recreated it.
AssertionError
at ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/dulwich/pack.py:698 in _object_offset
694│
695│ Args:
696│ sha: A *binary* SHA string. (20 characters long)_
697│ """
→ 698│ assert len(sha) == 20
699│ idx = ord(sha[:1])
700│ if idx == 0:
701│ start = 0
702│ else:
In my way, it reproduced like that:
hash
) repo {git = "path-to-repo", rev = "hash"}
, run poetry lock
git reset HEAD~1
, then make new commit on base of it, then force push the commit git push -f
(it has some commit with new hash2
)repo {git = "path-to-repo", rev = "hash2"}
, run poetry lock
, it has the error assert len(sha) == 20
I assume that older hash
is deleted when we made a force push commit, so poetry couldn't detect an older hash in github to compute SHA correctly.
As it's written above, removing .venv/
solves the problem
Bug and resolution still exist with Poetry 1.6.1. Removing repo in ~/.cache/pypoetry/virtualenvs/<redacted>-py3.11/src
allowed the poetry lock
command to succeed. Error was consistent regardless of using the git repo's full hash, the 11 char slug, or the first 20 chars. Maddening. Glad this thread exists.
I can confirm this bug still occurs in Poetry 1.7.1 as well. Maddening indeed.
Even more strange behaviour. I tried to install it with short SHA, and it failed on the first try and succeeded only on the second:
❯ poetry add "git+https://github.com/dask/dask-kubernetes.git#dfeca2b"
Failed to clone https://github.com/dask/dask-kubernetes.git at 'dfeca2b', verify ref exists on remote.
❯ poetry add "git+https://github.com/dask/dask-kubernetes.git#dfeca2b38fe504692091c153d297010004746aa7"
AssertionError
at ~/.local/pipx/venvs/poetry/lib/python3.10/site-packages/dulwich/pack.py:742 in _object_offset
738│
739│ Args:
740│ sha: A *binary* SHA string. (20 characters long)_
741│ """
→ 742│ assert len(sha) == 20
743│ idx = ord(sha[:1])
744│ if idx == 0:
745│ start = 0
746│ else:
❯ poetry add "git+https://github.com/dask/dask-kubernetes.git#dfeca2b"
Updating dependencies
Resolving dependencies... (2.4s)
Package operations: 0 installs, 1 update, 0 removals
• Updating dask-kubernetes (0+untagged.571.g4ec02c5 4ec02c5 -> 0+untagged.571.g4ec02c5 dfeca2b
)
Writing lock file
That is another weird error. Installing the package from the scratch gets a different error. The repository contains all required metadata, however, poetry complaints that it is not:
❯ poetry add "git+https://github.com/dask/dask-kubernetes.git#dfeca2b"
Unable to determine package info for path: /home/dmitrybalabka/src/test-poetry/.venv/src/dask-kubernetes
Command ['/tmp/tmpipdj6o9y/.venv/bin/python', '-I', '-W', 'ignore', '-c', "import build\nimport build.env\nimport pyproject_hooks\n\nsource = '/home/dmitrybalabka/src/test-poetry/.venv/src/dask-kubernetes'\ndest = '/tmp/tmpipdj6o9y/dist'\n\nwith build.env.DefaultIsolatedEnv() as env:\n builder = build.ProjectBuilder(\n source_dir=source,\n python_executable=env.python_executable,\n runner=pyproject_hooks.quiet_subprocess_runner,\n )\n env.install(builder.build_system_requires)\n env.install(builder.get_requires_for_build('wheel'))\n builder.metadata_path(dest)\n"] errored with the following return code 1
Error output:
Traceback (most recent call last):
File "<string>", line 9, in <module>
File "/tmp/tmpipdj6o9y/.venv/lib/python3.10/site-packages/build/__init__.py", line 174, in __init__
_validate_source_directory(source_dir)
File "/tmp/tmpipdj6o9y/.venv/lib/python3.10/site-packages/build/__init__.py", line 77, in _validate_source_directory
raise BuildException(msg)
build._exceptions.BuildException: Source /home/dmitrybalabka/src/test-poetry/.venv/src/dask-kubernetes does not appear to be a Python project: no pyproject.toml or setup.py
No fallback setup.py file was found to generate egg_info.
I had the repo cloning working, but it just "randomly" started failing in this way. It even does it without the hash. Can someone with more familiarity with poetry put in code to catch this error and recommend this solution?
The behavior is highly variable after purging the repo trying to be updated from .venv OR deleting the entire venv & lock:
## Works randomly
## Throws assertion error
❯ poetry update
Updating dependencies
Resolving dependencies... (1.1s)
Failed to clone git@github.com:-----/------.git at '03056d0', verify ref exists on remote.
Unable to determine package info for path: /Users/john/Library/Caches/pypoetry/virtualenvs/--------/src/--------
Command ['/var/folders/lc/kj4_ngks6w98yhrz7518cdb40000gp/T/tmpmz0p7l2s/.venv/bin/python', '-I', '-W', 'ignore', '-c', "import build\nimport build.env\nimport pyproject_hooks\n\nsource = '/Users/john/Library/Caches/pypoetry/virtualenvs/-------/src/-------'\ndest = '/var/folders/lc/kj4_ngks6w98yhrz7518cdb40000gp/T/tmpmz0p7l2s/dist'\n\nwith build.env.DefaultIsolatedEnv() as env:\n builder = build.ProjectBuilder(\n source_dir=source,\n python_executable=env.python_executable,\n runner=pyproject_hooks.quiet_subprocess_runner,\n )\n env.install(builder.build_system_requires)\n env.install(builder.get_requires_for_build('wheel'))\n builder.metadata_path(dest)\n"] errored with the following return code 1
Error output:
Traceback (most recent call last):
File "<string>", line 9, in <module>
File "/var/folders/lc/kj4_ngks6w98yhrz7518cdb40000gp/T/tmpmz0p7l2s/.venv/lib/python3.9/site-packages/build/__init__.py", line 174, in __init__
_validate_source_directory(source_dir)
File "/var/folders/lc/kj4_ngks6w98yhrz7518cdb40000gp/T/tmpmz0p7l2s/.venv/lib/python3.9/site-packages/build/__init__.py", line 77, in _validate_source_directory
raise BuildException(msg)
build._exceptions.BuildException: Source /Users/john/Library/Caches/pypoetry/virtualenvs/--------/src/------- does not appear to be a Python project: no pyproject.toml or setup.py
No fallback setup.py file was found to generate egg_info.
This was seriously working without a hitch for months... what could have changed system-wide? I removed the entire venv and the lock, and the same thing is happening. I used 6-char SHA on Monday, and I just started getting the error today. The exact preceding incidents were:
poetry update
, requesting an older version of the dependency than the localIn my situation, the issue turned out to be a caching issue. For some reason, the package folder for the downloaded package source was empty. When I deleted it and ran poetry install, it worked fine.
Mine was located at <venv>/src/<package_name>
.
Possible reasons:
Another confirmation that nuking the dependency from the venv's src/
directory got it working again.
Like gogobera said:
Maddening. Glad this thread exists.
In my situation, the issue turned out to be a caching issue. For some reason, the package folder for the downloaded package source was empty. When I deleted it and ran poetry install, it worked fine. Mine was located at
<venv>/src/<package_name>
.Possible reasons:
- network issue when downloading the package
- I deleted the package but the folder stayed there because of cosmic rays
Seems to work well indeed, thanks for the tip
I have the same error (see https://github.com/python-poetry/poetry/issues/9809). I removed the .venv
folder and reinstalled, but it persists.
Poetry version: Poetry (version 1.4.1)
Python version: Python: 3.9.15
OS version and name: macOS 13.2.1
pyproject.toml: https://gist.github.com/sg-s/07ae0c878981d15b5c22d2adc7d74f3d
[x] I am on the latest stable Poetry version, installed using a recommended method.
[x] I have searched the issues of this repo and believe that this is not a duplicate.
[x] I have consulted the FAQ and blog for any relevant entries or release notes.
[x] If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option) and have included the output below.Issue
what i'm trying to do
what i expected to happen
it to install, or at least give me some error about access.
what i got instead
an error that the length of SHA string isn't 20
base error
detailed error