{"record":{"id":"960df2fc099d33b1","repo":"astral-sh/uv","slug":"the-file-appears-to-be-a-file-but-overr","errorCode":null,"errorMessage":"The file `{}` appears to be a `{}` file, but overrides must be specified in `requirements.txt` format","messagePattern":"The file `(.+?)` appears to be a `(.+?)` file, but overrides must be specified in `requirements\\.txt` format","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/uv-requirements/src/sources.rs","lineNumber":159,"sourceCode":"            .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(\"-\") {\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 overrides 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 overrides 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\"))","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/astral-sh/uv/blob/f1a42680ff5272232d65748acf338b19778dde24/crates/uv-requirements/src/sources.rs#L141-L177","documentation":"Thrown by RequirementsSource::from_overrides_txt (crates/uv-requirements/src/sources.rs:159) when the --overrides path ends with pyproject.toml, setup.py, or setup.cfg. Override files must use requirements.txt syntax (lines that replace pinned versions), and Python project metadata files are explicitly blocked so uv does not silently misread them.","triggerScenarios":"Running `uv pip install --overrides pyproject.toml ...` (or a path ending in setup.py / setup.cfg), or calling from_overrides_txt with such a path; the check uses Path::ends_with so nested paths like ./sub/pyproject.toml also match.","commonSituations":"Users coming from pip's `--constraint pyproject.toml` habits apply it to --overrides; monorepo scripts glob all pyproject.toml files into an overrides list; users try to override versions declared in their own project metadata.","solutions":["Create an overrides.txt with the replacement pins (`package==1.2.3` per line) and pass that via --overrides","To change a dependency of the current project, edit the pyproject.toml dependency table instead of using --overrides","To override versions resolved from another project, extract its dependencies to a .txt file first (e.g. `uv export`)"],"exampleFix":"# before\nuv pip install -r requirements.txt --overrides pyproject.toml\n# after\n# overrides.txt: `flask==3.0.0`\nuv pip install -r requirements.txt --overrides overrides.txt","handlingStrategy":"validation","validationCode":"fn overrides_path_ok(path: &Path) -> bool {\n    path == Path::new(\"-\")\n        || ![\"pyproject.toml\", \"setup.py\", \"setup.cfg\"]\n            .iter()\n            .any(|name| path.ends_with(name))\n}\n\nif !overrides_path_ok(&path) {\n    return Err(anyhow::anyhow!(\"{path:?} is project metadata; write overrides to a .txt file\"));\n}","typeGuard":null,"tryCatchPattern":"match RequirementsSource::from_overrides_txt(path) {\n    Err(err) if err.to_string().contains(\"overrides must be specified in `requirements.txt` format\") => {\n        // skip or substitute an overrides.txt\n    }\n    source => source?,\n}","preventionTips":["Maintain a dedicated overrides.txt instead of reusing project metadata files","When scripting against many projects, never feed their pyproject.toml paths into --overrides","To change project deps, edit the dependency table, not overrides"],"tags":["uv","overrides","pyproject-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"}