{"record":{"id":"fb0e5a01df3d70e1","repo":"astral-sh/ruff","slug":"lockfile-not-found-at-lockfile-path-run-with","errorCode":null,"errorMessage":"Lockfile not found at '{lockfile_path}'. Run with `MDTEST_UPGRADE_LOCKFILES=1` to generate it.","messagePattern":"Lockfile not found at '(.+?)'\\. Run with `MDTEST_UPGRADE_LOCKFILES=1` to generate it\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ty_test/src/external_dependencies.rs","lineNumber":88,"sourceCode":"        },\n        PythonPlatform::All => {\n            bail!(\"For an mdtest with external dependencies, a Python platform must be specified\");\n        }\n    };\n\n    let upgrade_lockfile = std::env::var(\"MDTEST_UPGRADE_LOCKFILES\").is_ok_and(|v| v == \"1\");\n    let use_locked = if upgrade_lockfile {\n        // In upgrade mode, we'll generate a new lockfile\n        false\n    } else if lockfile_path.exists() {\n        // Copy existing lockfile to temp directory\n        let temp_lockfile = temp_path.join(\"uv.lock\");\n        std::fs::copy(lockfile_path, temp_lockfile.as_std_path())\n            .with_context(|| format!(\"Failed to copy lockfile from '{lockfile_path}'\"))?;\n        true\n    } else {\n        // No existing lockfile - error in normal mode\n        bail!(\n            \"Lockfile not found at '{lockfile_path}'. Run with `MDTEST_UPGRADE_LOCKFILES=1` to generate it.\",\n        );\n    };\n\n    // Run `uv sync` to install dependencies\n    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() {","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/astral-sh/ruff/blob/26f38c119cac42e4d320ba08f09224fdec74af2c/crates/ty_test/src/external_dependencies.rs#L70-L106","documentation":"When setup_venv runs in normal (locked) mode it copies the committed uv.lock into the temporary venv directory before `uv sync`. If the expected lockfile does not exist on disk, the harness bails and tells you to regenerate it with MDTEST_UPGRADE_LOCKFILES=1.","triggerScenarios":"Running an external-dependency mdtest (MDTEST_EXTERNAL=1) where the uv.lock next to the mdtest directory was never committed, was deleted, or the test was moved/renamed so its lockfile path no longer matches.","commonSituations":"Adding a new external mdtest without generating its lockfile; a fresh clone missing generated artifacts; renaming the external/ subdirectory without moving uv.lock.","solutions":["Run once with MDTEST_UPGRADE_LOCKFILES=1 (plus MDTEST_EXTERNAL=1) to generate the lockfile, then commit it","Or run `uv run crates/ty_python_semantic/mdtest.py -e external/` which manages this for you","Verify uv.lock exists at the path referenced by the mdtest's external-dependencies config"],"exampleFix":"// before\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# then commit the generated uv.lock and re-run in locked mode","handlingStrategy":"validation","validationCode":"lockfile=\"crates/ty_python_semantic/resources/mdtest/external/uv.lock\"\n[ -f \"$lockfile\" ] || { echo \"missing $lockfile; run with MDTEST_UPGRADE_LOCKFILES=1\"; exit 1; }","typeGuard":null,"tryCatchPattern":"match std::path::Path::new(lockfile_path).try_exists() {\n    Ok(true) => proceed(),\n    Ok(false) => eprintln!(\"Lockfile missing at {lockfile_path}; set MDTEST_UPGRADE_LOCKFILES=1\"),\n    Err(e) => eprintln!(\"cannot stat lockfile: {e}\"),\n}","preventionTips":["Commit uv.lock whenever you add or move an external-dependency mdtest","Run the harness once with MDTEST_UPGRADE_LOCKFILES=1 after creating new external tests","Check for the lockfile in CI before running external mdtests"],"tags":["testing","mdtest","lockfile","uv"],"backgroundTag":"missing-lockfile","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"}