{"record":{"id":"2fcce5970fc212e8","repo":"astral-sh/uv","slug":"the-file-appears-to-be-a-pylock-toml-file-2fcce5","errorCode":null,"errorMessage":"The file `{}` appears to be a `pylock.toml` file, but constraints must be specified in `requirements.txt` format","messagePattern":"The file `(.+?)` appears to be a `pylock\\.toml` file, but constraints must be specified in `requirements\\.txt` format","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/uv-requirements/src/sources.rs","lineNumber":135,"sourceCode":"        if path == Path::new(\"-\") {\n            return Ok(Self::Extensionless(path));\n        }\n\n        for file_name in [\"pyproject.toml\", \"setup.py\", \"setup.cfg\"] {\n            if path.ends_with(file_name) {\n                return Err(anyhow::anyhow!(\n                    \"The file `{}` appears to be a `{}` file, but constraints must be specified in `requirements.txt` format\",\n                    path.user_display(),\n                    file_name\n                ));\n            }\n        }\n        if path\n            .file_name()\n            .and_then(OsStr::to_str)\n            .is_some_and(is_pylock_toml)\n        {\n            return Err(anyhow::anyhow!(\n                \"The file `{}` appears to be a `pylock.toml` file, but constraints must be specified in `requirements.txt` format\",\n                path.user_display(),\n            ));\n        } else if path\n            .extension()\n            .is_some_and(|ext| ext.eq_ignore_ascii_case(\"toml\"))\n        {\n            return Err(anyhow::anyhow!(\n                \"The file `{}` appears to be a TOML file, but constraints must be specified in `requirements.txt` format\",\n                path.user_display(),\n            ));\n        }\n        Ok(Self::RequirementsTxt(path))\n    }\n\n    /// Parse a [`RequirementsSource`] from an `overrides.txt` file.\n    pub fn from_overrides_txt(path: PathBuf) -> Result<Self> {\n        if path == Path::new(\"-\") {","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/astral-sh/uv/blob/f1a42680ff5272232d65748acf338b19778dde24/crates/uv-requirements/src/sources.rs#L117-L153","documentation":"Thrown by RequirementsSource::from_constraints_txt (crates/uv-requirements/src/sources.rs:135) when the file passed via --constraints/-c has a file name recognized as a pylock.toml lock file (is_pylock_toml matches pylock.toml and its versioned variants). Constraint files must use the requirements.txt format (bare `name==version` pins), and a PEP 751 lock file cannot fulfill that role. uv aborts up front instead of mis-parsing the TOML as requirements syntax.","triggerScenarios":"Running `uv pip install -c pylock.toml flask` or `uv pip compile --constraints pylock.toml`, or calling RequirementsSource::from_constraints_txt(PathBuf::from(\"pylock.toml\")) programmatically; `is_pylock_toml` matches the file-name component (e.g. pylock.2020.dev.toml variants also match).","commonSituations":"Teams migrating from pip-tools try to reuse an exported lock file as constraints; CI scripts point --constraints at a generated pylock.toml; users assume a lock file and a constraints file are interchangeable.","solutions":["Pass a requirements.txt-format constraints file instead: `uv pip install -c constraints.txt ...` where each line is `package==version`","Generate constraints from your lock with `uv export --format requirements-txt -o constraints.txt` and use that file","If your goal is to reproduce the locked environment, use `uv sync` or `uv pip install -r pylock.toml` rather than --constraints"],"exampleFix":"# before\nuv pip install -c pylock.toml flask\n# after\nuv export --format requirements-txt -o constraints.txt\nuv pip install -c constraints.txt flask","handlingStrategy":"validation","validationCode":"fn is_pylock_toml_name(path: &Path) -> bool {\n    path.file_name()\n        .and_then(std::ffi::OsStr::to_str)\n        .is_some_and(|name| {\n            name == \"pylock.toml\" || (name.starts_with(\"pylock.\") && name.ends_with(\".toml\"))\n        })\n}\n\n// before calling from_constraints_txt:\nif is_pylock_toml_name(&path) {\n    return Err(anyhow::anyhow!(\"{path:?} is a lock file; use a requirements.txt-format constraints file\"));\n}","typeGuard":null,"tryCatchPattern":"match RequirementsSource::from_constraints_txt(path) {\n    Err(err) if err.to_string().contains(\"pylock.toml\") => {\n        // fall back to exporting constraints from the lock\n    }\n    source => source?,\n}","preventionTips":["Standardize constraint files as *.txt in requirements.txt format","In CI, assert every --constraints argument ends with .txt and is not a pylock variant before invoking uv","Document that pylock.toml is install-only input in your project README"],"tags":["uv","constraints","pylock-toml","file-format","pip-interface"],"backgroundTag":null,"analyzedSha":"f1a42680ff5272232d65748acf338b19778dde24","analyzedAt":"2026-08-16T04:51:47.599Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}