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

Struggling with installs from git -- unearth.errors.UnpackError: fatal: couldn't find remote ref unknown #3107

Closed
1 task done
sydney-runkle opened this issue Aug 14, 2024 · 9 comments · Fixed by #3111
Closed
1 task done
Assignees
Labels
🐛 bug Something isn't working

Comments

@sydney-runkle
Copy link

sydney-runkle commented Aug 14, 2024

  • I have searched the issue tracker and believe that this is not a duplicate.

Hey folks, thanks for your awesome work on this package.

We've upgraded to v2.18.0, and are struggling with installs for the latest versions of packages from git. Specifically, we're getting this error:

unearth.errors.UnpackError: fatal: couldn't find remote ref unknown

You can see the full repro here: https://github.com/pydantic/pydantic/actions/runs/10392350698/job/28777332850?pr=10134

In our pyproject.toml file, we have dependencies listed as follows, which seems to be causing the problem.

 "pydantic-extra-types @ git+https://github.com/pydantic/pydantic-extra-types.git@main",

I've opened pydantic/pydantic#10134 to try to support this new pdm version, but am a bit stumped with the above error. Any advice / help is greatly appreciated!

@frostming, I'm guessing you might have some ideas?

@sydney-runkle
Copy link
Author

Seems like the resolution doesn't work correctly, despite the aforementioned specification:

git+https://github.com/pydantic/pydantic-extra-types.git@main
======== Resolution Result ========
pdm.termui:                            python None
pdm.termui:                              mike git+https://github.com/jimporter/mike.git@unknown
pdm.termui:              pydantic-extra-types git+https://github.com/pydantic/pydantic-extra-types.git@unknown

Not sure where this unknown is coming from...

@Viicos
Copy link
Contributor

Viicos commented Aug 14, 2024

I managed to find the commit that introduced the issue: 865fc62, this line:

pin = pin.copy_with(min(requirements[identifier], key=self.requirement_preference))

copies the Candidate instance with a new Requirement instance, missing the revision attribute.

@sydney-runkle
Copy link
Author

@Viicos, nice work. Great digging.

@sydney-runkle sydney-runkle changed the title Struggling with installs from git -- unearth.errors.UnpackError: fatal: couldn't find remote ref unknown Struggling with installs from git -- unearth.errors.UnpackError: fatal: couldn't find remote ref unknown Aug 14, 2024
@frostming
Copy link
Collaborator

frostming commented Aug 15, 2024

Sorry for that, how can I simply reproduce this issue? I tried with the following pyproject.toml:
@sydney-runkle

[project]
name = "myproject"
requires-python = ">=3.11"
dependencies = [
    "pydantic-extra-types @ git+https://github.com/pydantic/pydantic-extra-types.git@main",
]

[tool.pdm]
distribution = false

And couldn't reproduce with consecutive pdm install, pdm add and pdm remove.

copies the Candidate instance with a new Requirement instance, missing the revision attribute.

Yeah but the get_revision() will fallback to get revision from the prepared candidate if the .revision is None:

def get_revision(self) -> str:
if not self.req.is_vcs:
raise AttributeError("Non-VCS candidate doesn't have revision attribute")
if self.req.revision: # type: ignore[attr-defined]
return self.req.revision # type: ignore[attr-defined]
return self._prepared.revision if self._prepared else "unknown"

@Viicos
Copy link
Contributor

Viicos commented Aug 15, 2024

Yeah but the get_revision() will fallback to get revision from the prepared candidate if the .revision is None:

From my debugging last night _prepared was None, so it would fallback to "unknown".

Sorry for that, how can I simply reproduce this issue?

It's a bit hard to have a reproducible example. Your pyproject is good (I tried with the same one). You need to first run pdm install, it will create a fresh venv and a pdm.lock file. You can then try to add a dependency, e.g. pdm add requests -v. PDM will then use candidates from the lock file and this is where the issue will happen. You'll also notice that "unknown" is written back to the pdm.lock file as the revision attribute for the pydantic-extra-types package, so you need to revert this change to reproduce the issue again.

@frostming
Copy link
Collaborator

frostming commented Aug 15, 2024

You'll also notice that "unknown" is written back to the pdm.lock file as the revision attribute for the pydantic-extra-types package, so you need to revert this change to reproduce the issue again.

I've tried that, but it shows:

pdm.termui: ======== Resolution Result ========
pdm.termui:                 python None
pdm.termui:   pydantic-extra-types git+https://github.com/pydantic/pydantic-extra-types.git@49db83a9dfbdbec887f90ab78b0403720543c049
pdm.termui:               requests 2.32.3
pdm.termui:     charset-normalizer 3.3.2
pdm.termui:                   idna 3.7
pdm.termui:                urllib3 2.2.2
pdm.termui:                certifi 2024.7.4
pdm.termui:               pydantic 2.8.2
pdm.termui:          pydantic-core 2.20.1
pdm.termui:      typing-extensions 4.12.2
pdm.termui:        annotated-types 0.7.0

Even can't reproduce with pydantic full repo and same steps as workflow

@frostming
Copy link
Collaborator

frostming commented Aug 15, 2024

Did you turn on pypi.json_api config?

@Viicos
Copy link
Contributor

Viicos commented Aug 15, 2024

Did you turn on pypi.json config?

I don't believe so.


I created a repro repository: https://github.com/Viicos/pdm-218-issue. I realized it's even harder to reproduce. I believe the issue happens if you:

  • clone the repository.
  • run pdm install
  • run pdm cache clear
  • run pdm add requests -v (it should work)
  • run pdm add requests -v a second time (it should fail)

@frostming
Copy link
Collaborator

I created a repro repository: https://github.com/Viicos/pdm-218-issue. I realized it's even harder to reproduce. I believe the issue happens if you:

Thanks, that is helpful, will fix it soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
3 participants