Skip to content

Commit

Permalink
Set GIT_TERMINAL_PROMPT=0 when resolving dependencies
Browse files Browse the repository at this point in the history
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
  • Loading branch information
piegamesde committed Feb 25, 2025
1 parent 878497a commit f8bf20c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/uv-git/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
32 changes: 32 additions & 0 deletions crates/uv/tests/it/pip_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2174,6 +2174,38 @@ 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 <https://github.com/astral-sh/uv/issues/5107>
#[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";

// The path to a git binary may be arbitrary, filter and replace
let filters: Vec<_> = [("\\/([[:alpha:]]*\\/)*git", "/usr/bin/git")]
.into_iter()
.chain(context.filters())
.collect();

uv_snapshot!(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() {
Expand Down

0 comments on commit f8bf20c

Please sign in to comment.