{"record":{"id":"629d425bf7b3699e","repo":"astral-sh/uv","slug":"cannot-use-as-an-override-file","errorCode":null,"errorMessage":"Cannot use `{}` as an override file","messagePattern":"Cannot use `(.+?)` as an override file","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/uv-requirements/src/specification.rs","lineNumber":440,"sourceCode":"            } else {\n                None\n            }\n        }) {\n            return Err(anyhow::anyhow!(\n                \"Cannot use `{}` as a constraint file\",\n                pylock_toml.user_display()\n            ));\n        }\n\n        // Disallow `pylock.toml` files as overrides.\n        if let Some(pylock_toml) = overrides.iter().find_map(|source| {\n            if let RequirementsSource::PylockToml(path) = source {\n                Some(path)\n            } else {\n                None\n            }\n        }) {\n            return Err(anyhow::anyhow!(\n                \"Cannot use `{}` as an override file\",\n                pylock_toml.user_display()\n            ));\n        }\n\n        // Disallow `pylock.toml` files as excludes.\n        if let Some(pylock_toml) = excludes.iter().find_map(|source| {\n            if let RequirementsSource::PylockToml(path) = source {\n                Some(path)\n            } else {\n                None\n            }\n        }) {\n            return Err(anyhow::anyhow!(\n                \"Cannot use `{}` as an exclude file\",\n                pylock_toml.user_display()\n            ));\n        }","sourceCodeStart":422,"sourceCodeEnd":458,"githubUrl":"https://github.com/astral-sh/uv/blob/f1a42680ff5272232d65748acf338b19778dde24/crates/uv-requirements/src/specification.rs#L422-L458","documentation":"Thrown in RequirementsSpecification::from_sources (crates/uv-requirements/src/specification.rs:440) when the overrides list contains a RequirementsSource::PylockToml variant. Overrides are requirements.txt-format pins applied to the resolution; a full lock file is neither parsed nor applied that way, so uv rejects the combination at assembly time (mirrors error 43 at the API level).","triggerScenarios":"Programmatic from_sources call with a PylockToml source inside the overrides Vec; an upstream flow that classified an --overrides path as a pylock source before reaching this constructor; only the first match is reported.","commonSituations":"Automation layering a corporate lock file as overrides on user requirements; wrapper tools assembling source lists from globs.","solutions":["Drop the pylock.toml from the overrides list and supply overrides.txt-style pins instead","Export the pins: `uv export --format requirements-txt -o overrides.txt`","Reconsider the design — to install exactly the lock, use it as the requirements source, not an override"],"exampleFix":"# before (programmatic)\noverrides: vec![RequirementsSource::PylockToml(lock.into())],\n// after\noverrides: vec![RequirementsSource::RequirementsTxt(ovr.into())],","handlingStrategy":"validation","validationCode":"let bad = overrides.iter().any(|s| matches!(s, RequirementsSource::PylockToml(_)));\nif bad {\n    return Err(anyhow::anyhow!(\"refusing to assemble spec: pylock.toml is not an override source\"));\n}","typeGuard":"fn is_pylock_source(s: &RequirementsSource) -> bool {\n    matches!(s, RequirementsSource::PylockToml(_))\n}","tryCatchPattern":"match RequirementsSpecification::from_sources(/* .. */).await {\n    Err(err) if err.to_string().contains(\"as an override file\") => {\n        // replace with an exported overrides.txt and reassemble\n    }\n    spec => spec?,\n}","preventionTips":["Generate overrides via `uv export`, never reuse lock paths","Guard override lists with a matches!(PylockToml) check in wrappers","Separate lock inputs from pin inputs in your config schema"],"tags":["uv","overrides","pylock-toml","api-misuse"],"backgroundTag":null,"analyzedSha":"f1a42680ff5272232d65748acf338b19778dde24","analyzedAt":"2026-08-16T04:51:47.599Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}