Skip to content

Commit

Permalink
fix: improve the error message to tell user how to fix it (#2396)
Browse files Browse the repository at this point in the history
  • Loading branch information
frostming authored Nov 13, 2023
1 parent b71956b commit 44f7a76
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/2358.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve the error message when a specific package can't be found in the lockfile.
9 changes: 8 additions & 1 deletion src/pdm/models/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,14 @@ def _identify_candidate(self, candidate: Candidate) -> CandidateKey:
)

def _get_dependencies_from_lockfile(self, candidate: Candidate) -> CandidateInfo:
return self.candidate_info[self._identify_candidate(candidate)]
err = (
f"Missing package {candidate.identify()} from the lockfile, "
"the lockfile may be broken. Run `pdm update` to fix it."
)
try:
return self.candidate_info[self._identify_candidate(candidate)]
except KeyError as e: # pragma: no cover
raise CandidateNotFound(err) from e

def dependency_generators(self) -> Iterable[Callable[[Candidate], CandidateInfo]]:
return (
Expand Down

0 comments on commit 44f7a76

Please sign in to comment.