{"record":{"id":"18e9900f543e8798","repo":"astral-sh/uv","slug":"cannot-specify-overrides-with-a-pylock-toml-file","errorCode":null,"errorMessage":"Cannot specify overrides with a `pylock.toml` file","messagePattern":"Cannot specify overrides with a `pylock\\.toml` file","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/uv-requirements/src/specification.rs","lineNumber":483,"sourceCode":"            } else {\n                None\n            }\n        }) {\n            if requirements\n                .iter()\n                .any(|source| !matches!(source, RequirementsSource::PylockToml(..)))\n            {\n                return Err(anyhow::anyhow!(\n                    \"Cannot specify additional requirements alongside a `pylock.toml` file\",\n                ));\n            }\n            if !constraints.is_empty() {\n                return Err(anyhow::anyhow!(\n                    \"Cannot specify constraints with a `pylock.toml` file\"\n                ));\n            }\n            if !overrides.is_empty() {\n                return Err(anyhow::anyhow!(\n                    \"Cannot specify overrides with a `pylock.toml` file\"\n                ));\n            }\n\n            // If we have a `pylock.toml`, disallow specifying paths for groups; instead, require\n            // that all groups refer to the `pylock.toml` file.\n            if let Some(groups) = groups {\n                let mut names = Vec::new();\n                for group in &groups.groups {\n                    if group.path.is_some() {\n                        return Err(anyhow::anyhow!(\n                            \"Cannot specify paths for groups with a `pylock.toml` file; all groups must refer to the `pylock.toml` file\"\n                        ));\n                    }\n                    names.push(group.name.clone());\n                }\n\n                if !names.is_empty() {","sourceCodeStart":465,"sourceCodeEnd":501,"githubUrl":"https://github.com/astral-sh/uv/blob/f1a42680ff5272232d65748acf338b19778dde24/crates/uv-requirements/src/specification.rs#L465-L501","documentation":"Thrown in RequirementsSpecification::from_sources (crates/uv-requirements/src/specification.rs:483) when requirements include a pylock.toml and the overrides list is non-empty. Overrides rewrite version constraints during resolution, but a lock file's versions are already fixed, so applying overrides is meaningless and rejected.","triggerScenarios":"`uv pip install -r pylock.toml --overrides overrides.txt`; programmatic from_sources with a PylockToml requirement plus a populated overrides Vec.","commonSituations":"Security-patch pipelines that force versions via overrides meeting locked installs; leftover --overrides flags in scripts after switching to pylock.toml.","solutions":["Remove --overrides when installing from pylock.toml","Bake the forced versions into the lock: update the source project with the pinned versions and re-export the lock","For upgrading a locked environment, regenerate the lock rather than overriding at install time"],"exampleFix":"# before\nuv pip install -r pylock.toml --overrides overrides.txt\n# after\nuv pip install -r pylock.toml","handlingStrategy":"validation","validationCode":"let has_pylock = requirements.iter().any(|s| matches!(s, RequirementsSource::PylockToml(_)));\nif has_pylock && !overrides.is_empty() {\n    return Err(anyhow::anyhow!(\"overrides are not applicable alongside a pylock.toml\"));\n}","typeGuard":"fn is_pylock_source(s: &RequirementsSource) -> bool {\n    matches!(s, RequirementsSource::PylockToml(_))\n}","tryCatchPattern":"match RequirementsSpecification::from_sources(requirements, constraints, overrides, /* .. */).await {\n    Err(err) if err.to_string().contains(\"Cannot specify overrides with a `pylock.toml`\") => {\n        // clear the overrides list and retry\n    }\n    spec => spec?,\n}","preventionTips":["Fold forced versions into the lock by regenerating it","Strip --overrides flags in wrappers when the requirement source is a lock","Audit security-patch pipelines that layer overrides onto locked installs"],"tags":["uv","pylock-toml","overrides","api-misuse","pip-interface"],"backgroundTag":null,"analyzedSha":"f1a42680ff5272232d65748acf338b19778dde24","analyzedAt":"2026-08-16T04:51:47.599Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}