Retain the cache lock and temporary caches during `uv run` and `uvx` (#15990)

We're seeing reports of a regression from
https://github.com/astral-sh/uv/pull/15888 where `--no-cache` causes `uv
run` and `uvx` to fail to spawn a command.

The intent of this code was to allow destructive cache operations
_after_ we'd finished setting up the environment. However, it's unclear
to me that it's safe to run `uv cache clean` during a `uv run` operation
(e.g., `uv run --script` uses an environment in the cache) and, more
importantly, we cannot drop non-persistent caches (e.g., from
`--no-cache`) as they include the environment we're spawning the command
in.

Alternative to #15977 which retains release of the lock — we may want to
consider that approach still but this regression needs to be resolved
quickly.

Closes https://github.com/astral-sh/uv/issues/15989
Closes https://github.com/astral-sh/uv/issues/15987
Closes https://github.com/astral-sh/uv/issues/15967
This commit is contained in:
Zanie Blue 2025-09-22 15:41:07 -05:00 committed by GitHub
parent 1224f65b13
commit a502464f82
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 0 additions and 6 deletions

View File

@ -1309,9 +1309,6 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl
process.env(EnvVars::VIRTUAL_ENV, interpreter.sys_prefix().as_os_str());
}
// Unblock cache removal operations.
drop(cache);
// Spawn and wait for completion
// Standard input, output, and error streams are all inherited
// TODO(zanieb): Throw a nicer error message if the command is not found

View File

@ -386,9 +386,6 @@ pub(crate) async fn run(
args.iter().map(|arg| arg.to_string_lossy()).join(" ")
);
// Unblock cache removal operations.
drop(cache);
let handle = match process.spawn() {
Ok(handle) => Ok(handle),
Err(err) if err.kind() == std::io::ErrorKind::NotFound => {