{"record":{"id":"4c3d881ffce13302","repo":"astral-sh/ruff","slug":"expected-uv-to-create-a-lockfile-at","errorCode":null,"errorMessage":"Expected uv to create a lockfile at '{}'","messagePattern":"Expected uv to create a lockfile at '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ty_test/src/external_dependencies.rs","lineNumber":138,"sourceCode":"            );\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            );\n        }\n    }\n\n    let venv_path = temp_path.join(\".venv\");\n\n    copy_site_packages_to_db(db, &venv_path, dest_venv_path, python_version)\n}\n\n/// Copy the site-packages directory from a real virtual environment to the in-memory filesystem of `db`.\n///\n/// This recursively copies all files from the venv's site-packages directory into the\n/// in-memory filesystem at the specified destination path.\nfn copy_site_packages_to_db(\n    db: &mut Db,\n    venv_path: &SystemPath,","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/astral-sh/ruff/blob/26f38c119cac42e4d320ba08f09224fdec74af2c/crates/ty_test/src/external_dependencies.rs#L120-L156","documentation":"In ty's test harness, `setup_venv` creates a virtual environment and runs `uv` to generate a `uv.lock` lockfile in a temp directory, then copies it to the expected location. This error is thrown when `uv` completed without leaving a lockfile at the expected temp path, meaning the external dependency provisioning failed silently.","triggerScenarios":"Calling the mdtest/external-dependencies test setup when the `uv lock`/install command exits successfully but no `uv.lock` exists at `temp_path.join(\"uv.lock\")`.","commonSituations":"A broken or overridden `uv` on PATH, a project configuration that disables lockfile creation, a `uv` version that writes the lockfile elsewhere, or filesystem/permission issues in the temp directory.","solutions":["Run the same `uv` command manually in a scratch directory and confirm it produces `uv.lock`; fix any uv config (e.g. `[tool.uv] package = false` or `--no-lock`-style options) that suppresses lockfile creation.","Check which `uv` binary is on PATH (`which uv`, `uv --version`) and align it with the version the test harness expects.","Verify write permissions and free space in the temp directory so uv can create the lockfile.","Re-run the test with `UV_VERBOSE`-style debugging or inspect the captured uv stderr to find why the lock step failed."],"exampleFix":"// before\n// setup runs: uv sync (no lock produced because lockfile generation is disabled)\n// after\n// setup runs: uv sync --locked  (or remove `[tool.uv]` settings that skip lockfile generation so uv.lock is created)","handlingStrategy":"validation","validationCode":"let temp_lockfile = temp_path.join(\"uv.lock\");\nif !temp_lockfile.exists() {\n    eprintln!(\"uv did not produce {}; aborting setup\", temp_lockfile.display());\n    std::process::exit(1);\n}","typeGuard":"fn has_lockfile(dir: &std::path::Path) -> bool { dir.join(\"uv.lock\").is_file() }","tryCatchPattern":"// Rust: use the anyhow context on the run and check lockfile existence right after the uv command\nlet output = run_uv(&venv_dir).context(\"uv provisioning failed\")?;\nanyhow::ensure!(temp_path.join(\"uv.lock\").exists(), \"uv produced no lockfile\");","preventionTips":["Pin a known-good uv version in CI and locally.","Never pass flags that disable lockfile generation to the provisioning command.","Assert `uv.lock` existence immediately after the uv step to fail fast with a clear message."],"tags":["testing","uv","lockfile","environment"],"backgroundTag":"lockfile-not-created","analyzedSha":"26f38c119cac42e4d320ba08f09224fdec74af2c","analyzedAt":"2026-09-05T10:32:37.492Z","contentChangedAt":"2026-09-05T10:32:37.492Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}