pdm icon indicating copy to clipboard operation
pdm copied to clipboard

add a `--no-input` options to pdm sync for automation scenario

Open deronnax opened this issue 1 year ago • 4 comments

Is your feature/enhancement proposal related to a problem? Please describe.

Hello. We use PDM a lot in CI and in Docker build with a private PyPI registry, where we often provides credentials with a .netrc file. When there is a problem with this credentials, PDM fails with this very misleading error that confuses all our developers:

17.18   File "/usr/local/lib/python3.11/site-packages/requests/hooks.py", line 30, in dispatch_hook
17.18     _hook_data = hook(hook_data, **kwargs)
17.18                  ^^^^^^^^^^^^^^^^^^^^^^^^^
17.18   File "/usr/local/lib/python3.11/site-packages/unearth/auth.py", line 415, in handle_401
17.18     username, password, save = self._prompt_for_password(parsed.netloc)
17.18                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17.18   File "/usr/local/lib/python3.11/site-packages/pdm/models/auth.py", line 54, in _prompt_for_password
17.18     return super()._prompt_for_password(netloc)
17.18            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17.18   File "/usr/local/lib/python3.11/site-packages/unearth/auth.py", line 369, in _prompt_for_password
17.18     username = input(f"User for {netloc}: ")
17.18                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17.18 EOFError: EOF when reading a line

Describe the solution you'd like

We would enjoy an option like apt-get install --yes or poetry --no-interaction to inform PDM that it's not facing an human and thus it is useless to ressort to a prompt, just fail showing the problem. Since Poetry has --no-interaction, this one should be preferred I think. Cheers

deronnax avatar Jun 11 '24 10:06 deronnax

The prompt shows if -v is passed

frostming avatar Jun 11 '24 10:06 frostming

I don't think the verbose mode should include "showing a prompt in case of missing credentials". In our CI and docker build, we want the verbose mode but not the prompt.

deronnax avatar Jun 11 '24 12:06 deronnax

I don't think the verbose mode should include "showing a prompt in case of missing credentials". In our CI and docker build, we want the verbose mode but not the prompt.

True, but the opposite holds: when -v is not passed, prompt can't be shown because the output is hidden behind a spinner. I am afraid adding another --no-interactive would make it confusing.

frostming avatar Jun 12 '24 01:06 frostming

Isn't it the problem that the spinner prevents a prompt to be shown? I am not sure but I think in other tools, a spinner doesn't prevent a prompt to be shown.

deronnax avatar Jun 13 '24 15:06 deronnax

Thank you very much, btw :)

deronnax avatar Aug 14 '24 12:08 deronnax