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

Git prompt hidden without --verbose flag #5107

Closed
zanieb opened this issue Jul 16, 2024 · 15 comments · Fixed by #11744
Closed

Git prompt hidden without --verbose flag #5107

zanieb opened this issue Jul 16, 2024 · 15 comments · Fixed by #11744
Labels
bug Something isn't working cli Related to the command line interface

Comments

@zanieb
Copy link
Member

zanieb commented Jul 16, 2024

The following command hung for a while:

❯ uv pip compile docs/requirements-insiders.in -o docs/requirements-insiders.txt --universal -p 3.12
Updating ssh://[email protected]/astral-sh/mkdocs-material-insiders.git (38c0b8187325c3bab386b666daf3518ac036f2f4)
The authenticity of host 'github.com (140.82.112.4)' can't be established.                                                            
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
Updating ssh://[email protected]/astral-sh/mkdocs-material-insiders.git (38c0b8187325c3bab386b666daf3518ac036f2f4)
⠹ Resolving dependencies...                                                                                             
              ^C

I cancelled it and re-ran with --verbose:

❯ uv pip compile docs/requirements-insiders.in -o docs/requirements-insiders.txt --universal -p 3.12 -v
DEBUG uv 0.2.23
DEBUG Starting Python discovery for Python 3.12
DEBUG Looking for exact match for request Python 3.12
DEBUG Searching for Python 3.12 in system path
DEBUG Found cpython 3.12.1 at `/Users/zb/workspace/uv/.venv/bin/python3` (virtual environment)
DEBUG Using Python 3.12.1 interpreter at .venv/bin/python3 for builds
DEBUG Using request timeout of 30s
DEBUG Fetching source distribution from Git: ssh://[email protected]/astral-sh/mkdocs-material-insiders.git
DEBUG Acquired lock for `ssh://github.com/astral-sh/mkdocs-material-insiders`
DEBUG Updating git source `Url { scheme: "ssh", cannot_be_a_base: false, username: "git", password: None, host: Some(Domain("github.com")), port: None, path: "/astral-sh/mkdocs-material-insiders.git", query: None, fragment: None }`
DEBUG Attempting GitHub fast path for: https://api.github.com/repos/astral-sh/mkdocs-material-insiders/commits/38c0b8187325c3bab386b666daf3518ac036f2f4
DEBUG failed to check github HTTP status client error (404 Not Found) for url (https://api.github.com/repos/astral-sh/mkdocs-material-insiders/commits/38c0b8187325c3bab386b666daf3518ac036f2f4)
DEBUG Performing a Git fetch for: ssh://[email protected]/astral-sh/mkdocs-material-insiders.git
The authenticity of host 'github.com (140.82.112.4)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? 

Then I could provide the information for the git prompt and move forward.

@zanieb zanieb added bug Something isn't working cli Related to the command line interface labels Jul 16, 2024
@charliermarsh
Copy link
Member

@ibraheemdev - Is this straightforward?

@zanieb
Copy link
Member Author

zanieb commented Jul 16, 2024

I don't see where we're gating this with the verbose flag with a casual look.

@charliermarsh
Copy link
Member

Not clear to me how this is appearing even with --verbose.

@zanieb
Copy link
Member Author

zanieb commented Jul 18, 2024

Yeah I was confused... haha. Tried to write a MRE but it just fails:

❯ cat ~/bin/git
#/usr/bin/env bash

echo "Content please"
read test

❯ uv pip install --no-cache "git+https://github.com/astral-test/uv-public-pypackage@0dacfd662c64cb4ceb16e6cf65a157a8b715b979"
Updating https://github.com/astral-test/uv-public-pypackage (0dacfd662c64cb4ceb16e6cf65a157a8b715b979)                                error: Git operation failed
  Caused by: process didn't exit successfully: `git init` (exit status: 1)
--- stdout
Content please

❯ uv pip install --no-cache "git+https://github.com/astral-test/uv-public-pypackage@0dacfd662c64cb4ceb16e6cf65a157a8b715b979" --verbose
DEBUG uv 0.2.26
DEBUG Searching for Python interpreter in system path
DEBUG Found cpython 3.12.3 at `/Users/zb/workspace/uv/.venv/bin/python3` (virtual environment)
DEBUG Using Python 3.12.3 environment at .venv/bin/python3
DEBUG Acquired lock for `.venv`
DEBUG At least one requirement is not satisfied: git+https://github.com/astral-test/uv-public-pypackage@0dacfd662c64cb4ceb16e6cf65a157a8b715b979
DEBUG Using request timeout of 30s
DEBUG Fetching source distribution from Git: https://github.com/astral-test/uv-public-pypackage
DEBUG Acquired lock for `https://github.com/astral-test/uv-public-pypackage`
DEBUG Updating git source `Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("github.com")), port: None, path: "/astral-test/uv-public-pypackage", query: None, fragment: None }`
error: Git operation failed
  Caused by: process didn't exit successfully: `git init` (exit status: 1)
--- stdout
Content please

@rhoboro
Copy link

rhoboro commented Oct 21, 2024

@zanieb @charliermarsh
Hi, I'm a big fan of uv! Thank you as always.

I have found the cause of this.
It seems that the tick of ResolverReporter is erasing the prompt for the git command.
Therefore, if this line is removed, no hang-up will occur.

root.enable_steady_tick(Duration::from_millis(200));

Could you fix this?
If you don't have time, please point me in the right direction and I'll try to create a PR.
( I am not an expert in Rust, so this may take some time 😅 )

@charliermarsh
Copy link
Member

charliermarsh commented Oct 21, 2024

Oh wow, that’s a great find and explains a lot!

@zanieb
Copy link
Member Author

zanieb commented Oct 21, 2024

@Viicos
Copy link
Contributor

Viicos commented Dec 17, 2024

I was hit by a similar issue when running:

uv pip install "git+https://github.com/typing/typing_extensions@main"

Note that the correct URL is https://github.com/python/typing_extensions. Without using the --verbose flag, I get the following output and it hangs forever:

Updating https://github.com/typing/typing_extensions (main)
Updating https://github.com/typing/typing_extensions (main)

Only when running in verbose mode, I get:

DEBUG failed to check github HTTP status client error (404 Not Found) for url (https://api.github.com/repos/typing/typing_extensions/commits/main)
DEBUG Performing a Git fetch for: https://github.com/typing/typing_extensions
Username for 'https://github.com':

I assume because the repo can't be found, uv delegates to the git CLI, and because the HTTPS URL was used, the git CLI will use HTTP auth (which is deprecated iirc, maybe it doesn't work anymore).

@zanieb
Copy link
Member Author

zanieb commented Feb 16, 2025

Same as #3783

@piegamesde
Copy link
Contributor

Looking at the code and how to resolve this, I fear that an animated spinner is fundamentally incompatible with an interactive prompt. I suggest either removing the animation, or entirely replacing all interactive prompts with a failure. Either way, the current situation is a huge foot gun and source of confusion. (There may be a third solution of detecting interactive prompts and disabling the spinner only then, but that sounds like it would be a lot of work and very brittle)

piegamesde added a commit to piegamesde/uv that referenced this issue Feb 24, 2025
The animation shadows any interactive authentication prompt which may
occur when resolving dependencies of private repos.

Fixes astral-sh#5107.
piegamesde added a commit to piegamesde/uv that referenced this issue Feb 24, 2025
The animation shadows any interactive authentication prompt which may
occur when resolving dependencies of private repos.

Fixes astral-sh#5107.
piegamesde added a commit to piegamesde/uv that referenced this issue Feb 25, 2025
The interactive terminal prompt is not compatible with our TUI spinner
animation, which will shadow the prompt and make it look like uv is
hanging forever.

Interactive auth is still supported via GUI mechanisms configured
through git, like SSH_ASKPASS.

This fixes astral-sh#5107
@piegamesde
Copy link
Contributor

As an alternative workaround to running uv with -v, setting GIT_TERMINAL_PROMPT=0 also works.

@RazerM
Copy link

RazerM commented Feb 25, 2025

This is something I've ran into. It's not the ideal or common scenario but there are use cases for providing credentials interactively.

pip does this well. pipx has the same problem as uv where the progress covers the prompt. I agree that disabling the prompt is better than appearing to hang, but it would be nice if an interactive prompt is at least possible with, for example, an --interactive option.

@piegamesde
Copy link
Contributor

An interactive prompt is still possible via git's SSH_ASKPASS configuration. uv does not need to bother handling these, as they start a UI element. I think there are other options for configuring git auth as well.

@RazerM
Copy link

RazerM commented Feb 25, 2025

The scenarios I am thinking of are not using SSH and do not have a GUI available.

piegamesde added a commit to piegamesde/uv that referenced this issue Feb 25, 2025
The interactive terminal prompt is not compatible with our TUI spinner
animation, which will shadow the prompt and make it look like uv is
hanging forever.

Interactive auth is still supported via GUI mechanisms configured
through git, like SSH_ASKPASS.

This fixes astral-sh#5107
@piegamesde
Copy link
Contributor

Confusingly, SSH_ASKPASS is not specific to SSH auth and can also prompt for basic HTTP auth. If no GUI is available, I recommend setting up a custom credentials-helper. I recently did this to pass the GitLab auth CI token into git via an environment variable

Of course it would be possible to have an option in uv to not set GIT_TERMINAL_PROMPT=0 while disabling the spinner animation, I'll leave this up to the uv devs to decide if such a feature would be worth its price

piegamesde added a commit to piegamesde/uv that referenced this issue Feb 25, 2025
The interactive terminal prompt is not compatible with our TUI spinner
animation, which will shadow the prompt and make it look like uv is
hanging forever.

Interactive auth is still supported via GUI mechanisms configured
through git, like SSH_ASKPASS.

This fixes astral-sh#5107
piegamesde added a commit to piegamesde/uv that referenced this issue Feb 25, 2025
The interactive terminal prompt is not compatible with our TUI spinner
animation, which will shadow the prompt and make it look like uv is
hanging forever.

Interactive auth is still supported via GUI mechanisms configured
through git, like SSH_ASKPASS.

This fixes astral-sh#5107
piegamesde added a commit to piegamesde/uv that referenced this issue Feb 25, 2025
The interactive terminal prompt is not compatible with our TUI spinner
animation, which will shadow the prompt and make it look like uv is
hanging forever.

Interactive auth is still supported via GUI mechanisms configured
through git, like SSH_ASKPASS.

This fixes astral-sh#5107
piegamesde added a commit to piegamesde/uv that referenced this issue Feb 25, 2025
The interactive terminal prompt is not compatible with our TUI spinner
animation, which will shadow the prompt and make it look like uv is
hanging forever.

Interactive auth is still supported via GUI mechanisms configured
through git, like SSH_ASKPASS.

This fixes astral-sh#5107
zanieb pushed a commit that referenced this issue Feb 25, 2025
## Summary

The animation shadows any interactive authentication prompt which may
occur when resolving dependencies of private repos.

Fixes #5107.

## Test Plan

I started creating `install_git_private_https_interactive` as a
regression test but am unsure how to test this because it is interactive
and I don't really know the test framework
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cli Related to the command line interface
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants