pypa / pipx

Install and Run Python Applications in Isolated Environments
https://pipx.pypa.io
MIT License
9.51k stars 396 forks source link

pipx run --spec git+ssh:// hides ssh authentication prompt #1418

Open cdleonard opened 1 month ago

cdleonard commented 1 month ago

Describe the bug

When SSH authentication is requested for an URL pipx will hang indefinitely with a message like ⣾ determining package name from 'git+ssh://....

You can work around this by passing -v which shows the SSH password prompt.

Same effect for SSH password prompt and passphrase prompt.

How to reproduce

Run pipx run --spec git+ssh:// for an URL that requires interactive authentication. Maybe by running ssh-add -d and running some github package.

Expected behavior

pipx should allow the ssh prompt to be seen.

It would also be acceptable to run in batch mode and throw an error.

Gitznik commented 1 month ago

pipx runs all pip commands with the no-input flag, as we expect pipx to be used in automated processes. In your case, this unfortunately means that no prompt is shown.

You should be able to fix your issue, by adding the SSH key to your SSH agent before running pipx. This should prevent the prompts, as pip and your SSH agent have all necessary information.

Alternatively, we could think about adding a flag to pipx, that explicitly enables interactive mode.

cdleonard commented 1 month ago

It seems that pip --no-input does not suppress git+ssh login prompts. It's likely just for prompts originating from pip itself?

The ssh prompt can be suppressed by GIT_SSH_COMMAND='ssh -oBatchMode=yes'. For other kinds of prompts it might sense to set GIT_TERMINAL_PROMPT=0.

This could be considered a pip bug, but at least when running pip --no-input and it prompts the prompt is actually visible.

I don't particularly see the need for a pipx interactive mode, it would be sufficient for it to fail instead of hang if authentication is missing.