{"record":{"id":"47da0a95c2bb4052","repo":"astral-sh/uv","slug":"the-file-appears-to-be-a-pyproject-toml-s","errorCode":null,"errorMessage":"The file `{}` appears to be a `pyproject.toml`, `setup.py`, or `setup.cfg` file, which must be in a directory","messagePattern":"The file `(.+?)` appears to be a `pyproject\\.toml`, `setup\\.py`, or `setup\\.cfg` file, which must be in a directory","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/uv-requirements/src/source_tree.rs","lineNumber":180,"sourceCode":"            project,\n            extras,\n        })\n    }\n\n    /// Resolve the [`RequiresDist`] metadata for a given source tree. Attempts to resolve the\n    /// requirements without building the distribution, even if the project contains (e.g.) a\n    /// dynamic version since, critically, we don't need to install the package itself; only its\n    /// dependencies.\n    async fn resolve_requires_dist(&self, source_tree: &SourceTree) -> Result<RequiresDist> {\n        // Convert to a buildable source.\n        let path = fs_err::canonicalize(source_tree.path()).with_context(|| {\n            format!(\n                \"Failed to canonicalize path to source tree: {}\",\n                source_tree.path().user_display()\n            )\n        })?;\n        let path = path.parent().ok_or_else(|| {\n            anyhow::anyhow!(\n                \"The file `{}` appears to be a `pyproject.toml`, `setup.py`, or `setup.cfg` file, which must be in a directory\",\n                path.user_display()\n            )\n        })?;\n\n        // If the path is a `pyproject.toml`, attempt to extract the requirements statically. The\n        // distribution database will do this too, but we can be even more aggressive here since we\n        // _only_ need the requirements. So, for example, even if the version is dynamic, we can\n        // still extract the requirements without performing a build, unlike in the database where\n        // we typically construct a \"complete\" metadata object.\n        if let Some(pyproject_toml) = source_tree.pyproject_toml() {\n            if let Some(metadata) = self.database.requires_dist(path, pyproject_toml).await? {\n                return Ok(metadata);\n            }\n        }\n\n        let Ok(url) = Url::from_directory_path(path).map(DisplaySafeUrl::from_url) else {\n            return Err(anyhow::anyhow!(\"Failed to convert path to URL\"));","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/astral-sh/uv/blob/f1a42680ff5272232d65748acf338b19778dde24/crates/uv-requirements/src/source_tree.rs#L162-L198","documentation":"Error \"The file `{}` appears to be a `pyproject.toml`, `setup.py`, or `setup.cfg` file, which must be in a directory\" thrown in astral-sh/uv.","triggerScenarios":"Thrown at crates/uv-requirements/src/source_tree.rs:180 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f1a42680ff5272232d65748acf338b19778dde24","analyzedAt":"2026-08-16T04:51:47.599Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}