PdmUsageError
should include explanation and proposed solution(s)
#2682
Labels
⭐ enhancement
Improvements for existing features
Our issue: Inadequate understanding of how PDM works
We're getting started with PDM at my company, switching over from
pip freeze >requirements.txt
, Poetry, and other solutions. I'm already a big fan of PDM after only using it for a few days because to me it seems like it's the only Python dependency management tool that does things correctly – working with standardpyproject.toml
keys, resolving dependencies correctly, defaulting to platform- and Python-version-independent lockfiles, etc. Really great work @frostming and team!However both while I was converting our project to now use PDM and while my teammates were onboarding to using the new PDM-based tooling, we realized that we don't have a full and correct understand of all of the semantics of various
pdm
subcommands and how they interact withpyproject.toml
,pdm.lock
, various dependenciy groups (both inpyproject.toml
andpdm.lock
!), and the list of actual packages installed, and what happens if any of these are out of sync.We specifically hit issues #2124 / #2253 and didn't really understand what is causing the
[PdmUsageError]: Requested groups not in lockfile
errors and what we should do differently to solve the error.We were adding new dependencies and dependency groups manually to
pyproject.toml
and runningpdm install
orpdm install -G :all
, but that failed with:[PdmUsageError]: Requested groups not in lockfile
. #2124 and #2253 are previously reported issues about this scenario.Proposed solution: Always offer explanations and workarounds or solutions for usage errors
Usage errors are always errors where PDM knows how to handle the situation (show the error message), but the user doesn't, otherwise they would have not run into the usage error.
As a general guideline I would always include these 2 or 3 things when a
PdmUsageError
is shown:In the specific case of #2124 / #2255:
pyproject.toml
, but not tometadata.groups
inpdm.lock
, and thuspdm install
(orpdm install -G :all
) won't work.pyproject.toml
vs groups within the lockfile and why it won't run when there is a mismatch. (See also our other related enhancement proposal: Better documentation and CLI help forpdm install/lock/update/add
semantics #2681.)pdm lock -G :all
and then re-running thepdm install
command worked. Another alternative that could be suggested would be runningpdm add -G <new-group-name>
for each of the new groups. Perhaps editingpdm.lock
'smetadata
would have also worked, we haven't tried. I think it's OK to list all possible solutions or again a link to more details in the docs.Contribution
Again, happy to contribute, if that helps!
The text was updated successfully, but these errors were encountered: