From 8b9c193b72c540e5466c2f01ad30051b2cb027b8 Mon Sep 17 00:00:00 2001 From: piegames Date: Tue, 25 Feb 2025 14:26:09 +0100 Subject: [PATCH] Set GIT_TERMINAL_PROMPT=0 when resolving dependencies 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 https://github.com/astral-sh/uv/issues/5107 --- crates/uv-git/src/git.rs | 4 ++++ crates/uv/tests/it/pip_install.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/crates/uv-git/src/git.rs b/crates/uv-git/src/git.rs index 1123939763a9..f8ce675dbb42 100644 --- a/crates/uv-git/src/git.rs +++ b/crates/uv-git/src/git.rs @@ -578,6 +578,10 @@ fn fetch_with_cli( disable_ssl: bool, ) -> Result<()> { let mut cmd = ProcessBuilder::new(GIT.as_ref()?); + // Fix for https://github.com/astral-sh/uv/issues/5107. + // Interactive prompts via GUI like SSH_ASKPASS still work + cmd.env("GIT_TERMINAL_PROMPT", "0"); + cmd.arg("fetch"); if tags { cmd.arg("--tags"); diff --git a/crates/uv/tests/it/pip_install.rs b/crates/uv/tests/it/pip_install.rs index f3a12c9a6ebd..69fec340d5e5 100644 --- a/crates/uv/tests/it/pip_install.rs +++ b/crates/uv/tests/it/pip_install.rs @@ -2174,6 +2174,32 @@ fn install_github_artifact_private_https_multiple_pat() { context.assert_installed("uv_private_pypackage", "0.1.0"); } +/// Fail to a package from a private GitHub repository using interactive authentication +/// It should fail gracefully, instead of silently hanging forever +/// Regression test for +#[test] +#[cfg(feature = "git")] +fn install_git_private_https_interactive() { + let context = TestContext::new("3.8"); + + let package = "uv-private-pypackage@ git+https://github.com/astral-test/uv-private-pypackage"; + + uv_snapshot!(context.filters(), context.pip_install().arg(package) + , @r###" + success: false + exit_code: 1 + ----- stdout ----- + + ----- stderr ----- + × Failed to download and build `uv-private-pypackage @ git+https://github.com/astral-test/uv-private-pypackage` + ├─▶ Git operation failed + ├─▶ failed to clone into: [CACHE_DIR]/git-v0/db/8401f5508e3e612d + ╰─▶ process didn't exit successfully: `/usr/bin/git fetch --force --update-head-ok 'https://github.com/astral-test/uv-private-pypackage' '+HEAD:refs/remotes/origin/HEAD'` (exit status: 128) + --- stderr + fatal: could not read Username for 'https://github.com': terminal prompts disabled + "###); +} + /// Install a package without using pre-built wheels. #[test] fn reinstall_no_binary() {