Skip to content

Comments

Disable interactive git terminal prompts during fetches#11744

Merged
zanieb merged 1 commit intoastral-sh:mainfrom
piegamesde:main
Feb 25, 2025
Merged

Disable interactive git terminal prompts during fetches#11744
zanieb merged 1 commit intoastral-sh:mainfrom
piegamesde:main

Conversation

@piegamesde
Copy link
Contributor

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

@piegamesde
Copy link
Contributor Author

It looks like the test drive is having at least some sort of git credentials configuration leaking through global user state. If I run it naively, it fails directly:

   Updating https://github.com/astral-test/uv-private-pypackage (HEAD)                                                                                                     × Failed to download and build `uv-private-pypackage @ git+https://github.com/astral-test/uv-private-pypackage`
  ├─▶ Git operation failed
  ├─▶ failed to clone into: /home/piegames/.cache/uv/git-v0/db/8401f5508e3e612d
  ╰─▶ process didn't exit successfully: `/home/piegames/.nix-profile/bin/git fetch --force --update-head-ok 'https://github.com/astral-test/uv-private-pypackage'
      '+HEAD:refs/remotes/origin/HEAD'` (exit status: 128)
      --- stderr
      remote: Repository not found.
      fatal: repository 'https://github.com/astral-test/uv-private-pypackage/' not found

But if I run it with my .git-credentials file deleted, I instead get the desired password prompt

    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.20s
     Running `/home/piegames/.cache/cargo-target/debug/uv pip install 'git+https://github.com/astral-test/uv-private-pypackage'`
   Updating https://github.com/astral-test/uv-private-pypackage (HEAD)
Resolving dependencies...                                                                                                                                                Username for 'https://github.com': piegamesde
   Updating https://github.com/astral-test/uv-private-pypackage (HEAD)                                                                                                   error: Git operation failed
  Caused by: failed to fetch into: /home/piegames/.cache/uv/git-v0/db/8401f5508e3e612d
  Caused by: process didn't exit successfully: `/home/piegames/.nix-profile/bin/git fetch --force --update-head-ok 'https://github.com/astral-test/uv-private-pypackage' '+HEAD:refs/remotes/origin/HEAD'` (exit status: 128)

(Which then also fails because I didn't use the correct credentials, but that's besides the point)

@zanieb
Copy link
Member

zanieb commented Feb 24, 2025

I'm not sure if this is the change we want. Disabling the spinner entirely seems like a loss. It's unclear to me if we even want to try to support interactive authentication here.

It looks like the test drive is having at least some sort of git credentials configuration leaking through global user state. If I run it naively, it fails directly:

Do we need to just change the git configuration home to a tmpdir or something?

@zanieb
Copy link
Member

zanieb commented Feb 24, 2025

cc @jtfmumm since this was on your list of projects

@piegamesde
Copy link
Contributor Author

Disabling the spinner entirely seems like a loss. It's unclear to me if we even want to try to support interactive authentication here.

If the spinner should stay, then interactive auth needs to go. I removed the spinner because it was the easier fix, but with some instructions I can also try to disable interactive auth instead. Keeping this PR as a hotfix in the meantime would also be okay for me.

This issue is a major road block for a project migration to uv, because the project has private dependencies and if these are not set up correctly beforehand the application will seemingly just hang forever.

@piegamesde
Copy link
Contributor Author

Turns out that disabling the prompt is pretty easy, and it even works with other interactive auth mechanisms outside of the CLI. This is clearly a better solution.

I'm not sure on whether the env variable should be set to all git calls to be sure, or only to the ones with operations which might prompt in the first place. Also, not sure how to make a proper regression test for this

Resolved 1 package in [TIME]
Prepared 1 package in [TIME]
Installed 1 package in [TIME]
+ uv-private-pypackage==0.1.0 (from git+https://***@github.com/astral-test/uv-private-pypackage@d780faf0ac91257d4d5a4f0c5a0e4509608c0071)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing this succeeds because the credentials are in the git cache. Is there a way to disable that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh it does fail in CI

8       │- + uv-private-pypackage==0.1.0 (from git+https://***@github.com/astral-test/uv-private-pypackage@d780faf0ac91257d4d5a4f0c5a0e4509608c0071)
          5 │+  × Failed to download and build `uv-private-pypackage @ git+[https://github.com/astral-test/uv-private-pypackage`](https://github.com/astral-test/uv-private-pypackage%60)
          6 │+  ├─▶ Git operation failed
          7 │+  ├─▶ failed to clone into: [CACHE_DIR]/git-v0/db/8401f5508e3e612d
          8 │+  ╰─▶ 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)
          9 │+      --- stderr
         10 │+      fatal: could not read Username for 'https://github.com/': terminal prompts disabled

Maybe you just need to update the snapshot?

We should also probably special-case this error, but we can track that in a new issue.

@zanieb
Copy link
Member

zanieb commented Feb 25, 2025

Thanks for looking into that!

@zanieb zanieb self-assigned this Feb 25, 2025
@piegamesde piegamesde force-pushed the main branch 4 times, most recently from 8b9c193 to f8bf20c Compare February 25, 2025 15:44
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 piegamesde marked this pull request as ready for review February 25, 2025 16:01
@zanieb zanieb changed the title Remove animated spinner when resolving dependencies Disable interactive git terminal prompts during fetches Feb 25, 2025
@zanieb zanieb added the bug Something isn't working label Feb 25, 2025
@zanieb zanieb merged commit 15ac3a9 into astral-sh:main Feb 25, 2025
74 checks passed
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");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zanieb -- Should this be an EnvVars?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, yeah. Though we don't read it, so it matters less. I can add it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still good source for documentation purposes internally like we annotate with #[attr_hidden] the other git env vars https://github.com/astral-sh/uv/blob/main/crates/uv-static/src/env_vars.rs#L454

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh thanks, I didn't notice we were hiding attrs.

loic-lescoat pushed a commit to loic-lescoat/uv that referenced this pull request Mar 2, 2025
)

## Summary

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

Fixes astral-sh#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
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Mar 6, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [astral-sh/uv](https://github.com/astral-sh/uv) | patch | `0.6.3` -> `0.6.4` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>astral-sh/uv (astral-sh/uv)</summary>

### [`v0.6.4`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#064)

[Compare Source](astral-sh/uv@0.6.3...0.6.4)

##### Enhancements

-   Upgrade pypy3.10 to v7.3.19 ([#&#8203;11814](astral-sh/uv#11814))
-   Allow configuring log verbosity from the CLI (i.e., `-vvv`) ([#&#8203;11758](astral-sh/uv#11758))
-   Warn when duplicate index names found in single file ([#&#8203;11824](astral-sh/uv#11824))

##### Bug fixes

-   Always store registry index on resolution packages ([#&#8203;11815](astral-sh/uv#11815))
-   Avoid error on relative paths in `uv tool uninstall` ([#&#8203;11889](astral-sh/uv#11889))
-   Avoid silently dropping errors in directory enumeration ([#&#8203;11890](astral-sh/uv#11890))
-   Disable interactive git terminal prompts during fetches ([#&#8203;11744](astral-sh/uv#11744))
-   Discover Windows registry (PEP 514) Python versions across 32/64-bit ([#&#8203;11801](astral-sh/uv#11801))
-   Don't panic on Ctrl-C in confirm prompt ([#&#8203;11706](astral-sh/uv#11706))
-   Fix non-directory in workspace on Windows ([#&#8203;11833](astral-sh/uv#11833))
-   Make interpreter caching robust to OS upgrades ([#&#8203;11875](astral-sh/uv#11875))
-   Respect `include-system-site-packages` in layered environments ([#&#8203;11873](astral-sh/uv#11873))
-   Suggest `uv tool update-shell` in PowerShell ([#&#8203;11846](astral-sh/uv#11846))
-   Update code page to `65001` before setting environment variables in virtual environments ([#&#8203;11831](astral-sh/uv#11831))
-   Use hash instead of full wheel name in wheels bucket ([#&#8203;11738](astral-sh/uv#11738))
-   Fix version string truncation while generating cache_key ([#&#8203;11830](astral-sh/uv#11830))
-   Explicitly handle ctrl-c in confirmation prompt instead of using a signal handler ([#&#8203;11897](astral-sh/uv#11897))

##### Performance

-   Avoid cloning to string when creating cache path ([#&#8203;11772](astral-sh/uv#11772))
-   Avoid redundant clones in version containment check ([#&#8203;11767](astral-sh/uv#11767))
-   Avoid string allocation when enumerating tool names ([#&#8203;11910](astral-sh/uv#11910))
-   Avoid using owned `String` for package name constructors ([#&#8203;11768](astral-sh/uv#11768))
-   Avoid using owned `String` in deserializers ([#&#8203;11764](astral-sh/uv#11764))
-   Migrate to `zlib-rs` (again) ([#&#8203;11894](astral-sh/uv#11894))
-   Remove unnecessary clones when adding package names ([#&#8203;11771](astral-sh/uv#11771))
-   Skip unquote allocation for non-quoted strings ([#&#8203;11813](astral-sh/uv#11813))
-   Use `SmallString` for filenames and URLs ([#&#8203;11765](astral-sh/uv#11765))
-   Use a Boxed slice for version specifiers ([#&#8203;11766](astral-sh/uv#11766))
-   Use matches over contains for extra value parsing ([#&#8203;11770](astral-sh/uv#11770))

##### Documentation

-   Avoid fallback to PyPI in mixed CPU/CUDA example ([#&#8203;11115](astral-sh/uv#11115))
-   Docs: Clarify that setting cache-keys overrides defaults ([#&#8203;11895](astral-sh/uv#11895))
-   Document our MSRV policy ([#&#8203;11898](astral-sh/uv#11898))
-   Fix reference to macOS cache path ([#&#8203;11845](astral-sh/uv#11845))
-   Fix typo in `no_default_groups` documentation and changelog ([#&#8203;11928](astral-sh/uv#11928))
-   Update the "Locking and syncing" page ([#&#8203;11647](astral-sh/uv#11647))
-   Update alternative indexes documentation to use new interface ([#&#8203;10826](astral-sh/uv#10826))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xODUuMCIsInVwZGF0ZWRJblZlciI6IjM5LjE4NS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Git prompt hidden without --verbose flag

4 participants