{"record":{"id":"a85156203ebab674","repo":"astral-sh/ruff","slug":"uv-sync-failed-to-run-with-exit-code-code-s","errorCode":null,"errorMessage":"`uv sync` failed to run with exit code `{code}`, stderr: {stderr}","messagePattern":"`uv sync` failed to run with exit code `(.+?)`, stderr: (.+?)","errorType":"console","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/ty_completion_bench/src/main.rs","lineNumber":88,"sourceCode":"        format!(\n            \"failed to convert file offset `{}` to 32-bit integer\",\n            args.offset\n        )\n    })?;\n\n    let uv_sync_output = std::process::Command::new(\"uv\")\n        .arg(\"sync\")\n        .current_dir(&project_dir)\n        .output()\n        .with_context(|| format!(\"failed to run `uv sync` in `{project_dir}`\"))?;\n    if !uv_sync_output.status.success() {\n        let code = uv_sync_output\n            .status\n            .code()\n            .map(|code| code.to_string())\n            .unwrap_or_else(|| \"UNKNOWN\".to_string());\n        let stderr = bstr::BStr::new(&uv_sync_output.stderr);\n        anyhow::bail!(\"`uv sync` failed to run with exit code `{code}`, stderr: {stderr}\")\n    }\n\n    let system = OsSystem::new(&project_dir);\n    let mut project_metadata = ProjectMetadata::discover(&project_dir, &system)?;\n    // Explicitly point ty to the .venv to avoid any set VIRTUAL_ENV variable to take precedence.\n    project_metadata.apply_override_options(Options {\n        environment: Some(EnvironmentOptions {\n            python: Some(RelativePathBuf::cli(\".venv\")),\n            ..EnvironmentOptions::default()\n        }),\n        ..Options::default()\n    });\n    let db = ProjectDatabase::fallible(project_metadata, system)?;\n\n    let start = std::time::Instant::now();\n    let mut completions = get_completions(&db, &args.file, offset)?;\n    let elapsed = std::time::Instant::now().duration_since(start);\n    eprintln!(\"total elapsed for initial completions request: {elapsed:?}\");","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/astral-sh/ruff/blob/672bb4edf04c84f8b0753346359daee4057158f2/crates/ty_completion_bench/src/main.rs#L70-L106","documentation":"The `ty_completion_bench` harness prepares each benchmark project by running `uv sync` inside it (creating/refreshing its `.venv`) before constructing the `ProjectDatabase`. This error means uv itself executed but exited non-zero; the exit code (or `UNKNOWN` if terminated by signal) and uv's raw stderr are embedded in the message so the underlying failure is visible.","triggerScenarios":"Offline or proxied network blocking package downloads; a `uv.lock` stale relative to `pyproject.toml`; the fixture's pinned Python version not installed; a corrupted or permission-locked `.venv` inside the benchmark project directory.","commonSituations":"Running benchmarks on machines without network access; after editing fixture dependencies without relocking; after a toolchain upgrade removed the pinned interpreter; corporate proxies rejecting PyPI.","solutions":["Reproduce manually: `cd <project-dir-from-error> && uv sync` and read the full uv output","Install the required interpreter (`uv python install <version>`) or update uv (`uv self update`) and retry","Refresh the lockfile (`uv lock`) after dependency edits, then re-run the bench","Check network/proxy settings (UV_HTTP_TIMEOUT, HTTPS_PROXY) if downloads are failing"],"exampleFix":"# before: bench aborts with `uv sync` failed ...\ncargo run -p ty_completion_bench -- ...\n# after: fix the environment first, then bench\ncd <fixture-project-dir> && uv sync && cd - && cargo run -p ty_completion_bench -- ...","handlingStrategy":"retry","validationCode":"cd \"$PROJECT_DIR\" && uv sync --dry-run >/dev/null 2>&1 \\\n  || echo \"warning: uv sync is not currently clean; bench may fail\" >&2","typeGuard":null,"tryCatchPattern":"# shell: bounded retry for transient uv failures (network flakes)\nfor i in 1 2; do\n  (cd \"$PROJECT_DIR\" && uv sync) && break || { [ \"$i\" = 2 ] && exit 1; sleep 5; }\ndone","preventionTips":["Run `uv sync` inside each benchmark project after pulling changes","Pin the Python version (`uv python install`) that the fixtures require","Keep uv and lockfiles in sync (`uv lock` after dependency edits) before benching"],"tags":["rust","benchmark","uv","dependency-sync","environment"],"backgroundTag":null,"analyzedSha":"672bb4edf04c84f8b0753346359daee4057158f2","analyzedAt":"2026-08-16T08:54:05.464Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}