Skip to content

Commit 1b0a911

Browse files
authored
fix(kernel-env): retry uv pip install with --refresh on stale cache (#1051)
* fix(kernel-env): retry uv pip install with --refresh on failure When uv's cached package index is stale, installing recently-published versions (e.g. nightly pre-releases) fails with "no version found". Retry once with --refresh to force a fresh index fetch, with no perf impact on the happy path. * fix(kernel-env): improve retry robustness and drop unrelated schema diffs - Clone install_args and insert --refresh instead of slicing by magic index - Log first-attempt stderr before retrying for easier debugging - Revert unrelated generated schema changes (webdriver ACL removal)
1 parent e5718c0 commit 1b0a911

File tree

1 file changed

+21
-0
lines changed
  • crates/kernel-env/src

1 file changed

+21
-0
lines changed

crates/kernel-env/src/uv.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,27 @@ pub async fn prepare_environment_in(
226226
.output()
227227
.await?;
228228

229+
// If install failed, retry once with --refresh to bypass stale index cache.
230+
// This handles cases where a recently-published version (e.g. a nightly pre-release)
231+
// isn't found because uv's cached package index is stale.
232+
let install_output = if !install_output.status.success() {
233+
let first_stderr = String::from_utf8_lossy(&install_output.stderr);
234+
info!(
235+
"uv pip install failed, retrying with --refresh. First attempt stderr: {}",
236+
first_stderr
237+
);
238+
let mut retry_args = install_args.clone();
239+
retry_args.insert(2, "--refresh".to_string());
240+
tokio::process::Command::new(&uv_path)
241+
.args(&retry_args)
242+
.stdout(Stdio::piped())
243+
.stderr(Stdio::piped())
244+
.output()
245+
.await?
246+
} else {
247+
install_output
248+
};
249+
229250
if !install_output.status.success() {
230251
tokio::fs::remove_dir_all(&venv_path).await.ok();
231252
let stderr = String::from_utf8_lossy(&install_output.stderr);

0 commit comments

Comments
 (0)