{"record":{"id":"88510becabc2f185","repo":"astral-sh/ruff","slug":"lockfile-is-out-of-date-use-one-of-these-commands","errorCode":null,"errorMessage":"Lockfile is out of date. Use one of these commands to regenerate it:\n\nuv run crates/ty_python_semantic/mdtest.py -e external/\n\nOr using cargo:\n\nMDTEST_EXTERNAL=1 MDTEST_UPGRADE_LOCKFILES=1 cargo test -p ty_python_semantic --test mdtest mdtest__external","messagePattern":"Lockfile is out of date\\. Use one of these commands to regenerate it:\n\nuv run crates/ty_python_semantic/mdtest\\.py -e external/\n\nOr using cargo:\n\nMDTEST_EXTERNAL=1 MDTEST_UPGRADE_LOCKFILES=1 cargo test -p ty_python_semantic --test mdtest mdtest__external","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ty_test/src/external_dependencies.rs","lineNumber":112,"sourceCode":"    let mut uv_sync = std::process::Command::new(\"uv\");\n    uv_sync\n        .args([\"sync\", \"--python-platform\", uv_platform])\n        .current_dir(temp_path.as_std_path());\n    if use_locked {\n        uv_sync.arg(\"--locked\");\n    }\n\n    let uv_sync_output = uv_sync\n        .output()\n        .context(\"Failed to run `uv sync`. Is `uv` installed?\")?;\n\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","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/astral-sh/ruff/blob/26f38c119cac42e4d320ba08f09224fdec74af2c/crates/ty_test/src/external_dependencies.rs#L94-L130","documentation":"setup_venv runs `uv sync --locked` against the committed lockfile. When uv reports that `uv.lock` needs to be updated but --locked was given, the committed lockfile is stale relative to the mdtest's declared dependencies, and the harness bails with regeneration instructions.","triggerScenarios":"Running an external-dependency mdtest after the mdtest's dependency declarations (or uv version) changed so the committed uv.lock no longer satisfies `uv sync --locked`.","commonSituations":"Editing an external mdtest's dependencies without regenerating uv.lock; rebasing over a dependency bump; uv resolving requirements differently after a toolchain update.","solutions":["Regenerate with `uv run crates/ty_python_semantic/mdtest.py -e external/`","Or run `MDTEST_EXTERNAL=1 MDTEST_UPGRADE_LOCKFILES=1 cargo test -p ty_python_semantic --test mdtest mdtest__external`, then commit the updated uv.lock","Diff the regenerated uv.lock to confirm only intended dependency changes"],"exampleFix":"// before (stale lockfile)\nMDTEST_EXTERNAL=1 cargo test -p ty_python_semantic --test mdtest mdtest__external\n// after\nMDTEST_EXTERNAL=1 MDTEST_UPGRADE_LOCKFILES=1 cargo test -p ty_python_semantic --test mdtest mdtest__external\n# commit the refreshed uv.lock, then re-run locked","handlingStrategy":"retry","validationCode":"cd crates/ty_python_semantic/resources/mdtest/external && \\\n  uv lock --check || echo \"lockfile stale: regenerate with MDTEST_UPGRADE_LOCKFILES=1\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["After editing external mdtest dependencies, always regenerate uv.lock and commit it","Run `uv lock --check` locally or in CI to detect staleness early","Pin the uv version used for lockfile generation to keep resolution stable"],"tags":["testing","mdtest","lockfile","uv","stale-dependencies"],"backgroundTag":"lockfile-out-of-date","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"}