astral-sh/uv · error · anyhow::Error

The file `{}` appears to be a `pylock.toml` file, but requir

Error message

The file `{}` appears to be a `pylock.toml` file, but requirements must be specified in `requirements.txt` format

What it means

Error "The file `{}` appears to be a `pylock.toml` file, but requirements must be specified in `requirements.txt` format" thrown in astral-sh/uv.

Source

Thrown at crates/uv-requirements/src/sources.rs:99

        if path == Path::new("-") {
            return Ok(Self::Extensionless(path));
        }

        for file_name in ["pyproject.toml", "setup.py", "setup.cfg"] {
            if path.ends_with(file_name) {
                return Err(anyhow::anyhow!(
                    "The file `{}` appears to be a `{}` file, but requirements must be specified in `requirements.txt` format",
                    path.user_display(),
                    file_name
                ));
            }
        }
        if path
            .file_name()
            .and_then(OsStr::to_str)
            .is_some_and(is_pylock_toml)
        {
            return Err(anyhow::anyhow!(
                "The file `{}` appears to be a `pylock.toml` file, but requirements must be specified in `requirements.txt` format",
                path.user_display(),
            ));
        } else if path
            .extension()
            .is_some_and(|ext| ext.eq_ignore_ascii_case("toml"))
        {
            return Err(anyhow::anyhow!(
                "The file `{}` appears to be a TOML file, but requirements must be specified in `requirements.txt` format",
                path.user_display(),
            ));
        }
        Ok(Self::RequirementsTxt(path))
    }

    /// Parse a [`RequirementsSource`] from a `constraints.txt` file.
    pub fn from_constraints_txt(path: PathBuf) -> Result<Self> {
        if path == Path::new("-") {

View on GitHub (pinned to f1a42680ff)

When it happens

Trigger: Thrown at crates/uv-requirements/src/sources.rs:99 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of astral-sh/uv@f1a42680ff (2026-08-16). Data as JSON: /api/errors/8d58d311f8490a6a. Report an issue: GitHub.