{"record":{"id":"466a71b323283641","repo":"astral-sh/ruff","slug":"uv-sync-failed-with-exit-code","errorCode":null,"errorMessage":"`uv sync` failed with exit code {:?}:\n{}","messagePattern":"`uv sync` failed with exit code (.+?):\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ty_test/src/external_dependencies.rs","lineNumber":123,"sourceCode":"\n    if !uv_sync_output.status.success() {\n        let stderr = String::from_utf8_lossy(&uv_sync_output.stderr);\n\n        if use_locked\n            && stderr.contains(\"`uv.lock` needs to be updated, but `--locked` was provided.\")\n        {\n            bail!(\n                \"Lockfile is out of date. Use one of these commands to regenerate it:\\n\\\n                 \\n\\\n                 uv run crates/ty_python_semantic/mdtest.py -e external/\\n\\\n                 \\n\\\n                 Or using cargo:\\n\\\n                 \\n\\\n                 MDTEST_EXTERNAL=1 MDTEST_UPGRADE_LOCKFILES=1 cargo test -p ty_python_semantic --test mdtest mdtest__external\"\n            );\n        }\n\n        bail!(\n            \"`uv sync` failed with exit code {:?}:\\n{}\",\n            uv_sync_output.status.code(),\n            stderr\n        );\n    }\n\n    // In upgrade mode, copy the generated lockfile back to the source location\n    if upgrade_lockfile {\n        let temp_lockfile = temp_path.join(\"uv.lock\");\n        let temp_lockfile = temp_lockfile.as_std_path();\n        if temp_lockfile.exists() {\n            std::fs::copy(temp_lockfile, lockfile_path)\n                .with_context(|| format!(\"Failed to write lockfile to '{lockfile_path}'\"))?;\n        } else {\n            bail!(\n                \"Expected uv to create a lockfile at '{}'\",\n                temp_lockfile.display()\n            );","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/astral-sh/ruff/blob/26f38c119cac42e4d320ba08f09224fdec74af2c/crates/ty_test/src/external_dependencies.rs#L105-L141","documentation":"Generic failure path of setup_venv: after running `uv sync` to install the mdtest's external dependencies into a temporary venv, the command exited non-zero for any reason not covered by the lockfile checks, so the harness bails with uv's exit code and stderr.","triggerScenarios":"`uv sync` fails inside setup_venv (crates/ty_test/src/external_dependencies.rs:123) due to network errors during dependency download, an unresolvable requirement set, a Python version mismatch with the venv, or uv not finding a valid interpreter.","commonSituations":"Working offline or behind a proxy that blocks PyPI; a dependency spec in the mdtest that cannot be resolved; an incompatible `requires-python` in the project; a broken or too-old `uv` on PATH.","solutions":["Read the stderr included in the message to identify uv's actual complaint","Check network/proxy access to the package index and retry","Fix unresolvable/conflicting dependency specs in the mdtest's external-dependencies declaration","Ensure a suitable `uv` is installed and on PATH (`uv --version`) and that a matching Python interpreter is available"],"exampleFix":"// diagnose\nbash -c 'MDTEST_EXTERNAL=1 cargo test -p ty_python_semantic --test mdtest mdtest__external 2>&1 | tail -40'\n// after fixing the underlying cause (e.g. corrected dependency spec)\n---\nexternal_dependencies:\n  dependencies:\n    - numpy==2.1.0   # was: numpy  (unpinned caused resolution failure)\n---","handlingStrategy":"try-catch","validationCode":"uv --version && uv python find  # confirm uv and a suitable interpreter exist\n","typeGuard":null,"tryCatchPattern":"let output = std::process::Command::new(\"uv\").args([\"sync\", \"--locked\"]).output()?;\nif !output.status.success() {\n    eprintln!(\"uv sync failed ({}): {}\",\n        output.status.code().unwrap_or(-1),\n        String::from_utf8_lossy(&output.stderr));\n}","preventionTips":["Ensure network/proxy access to the package index before running external mdtests","Keep `uv` up to date and on PATH; verify with `uv --version`","Pin mdtest dependency versions so resolution is deterministic","Read the stderr embedded in the message first — it names the underlying uv failure"],"tags":["testing","mdtest","uv","dependency-install","process-failure"],"backgroundTag":"uv-sync-failed","analyzedSha":"26f38c119cac42e4d320ba08f09224fdec74af2c","analyzedAt":"2026-09-05T10:32:37.492Z","contentChangedAt":"2026-09-05T10:32:37.492Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}