{"record":{"id":"0571841e29d334dd","repo":"astral-sh/uv","slug":"package-package-not-found-in-workspace","errorCode":null,"errorMessage":"Package `{package}` not found in workspace","messagePattern":"Package `(.+?)` not found in workspace","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/uv/src/commands/build_frontend.rs","lineNumber":373,"sourceCode":"    // If a `--package` or `--all-packages` was provided, adjust the source directory.\n    let packages = if let Some(package) = package {\n        if matches!(src, Source::File(_)) {\n            return Err(anyhow::anyhow!(\n                \"Cannot specify `--package` when building from a file\"\n            ));\n        }\n\n        let workspace = match workspace {\n            Ok(ref workspace) => workspace,\n            Err(err) => {\n                return Err(err).context(\"`--package` was provided, but no workspace was found\");\n            }\n        };\n\n        let package = workspace\n            .packages()\n            .get(package)\n            .ok_or_else(|| anyhow::anyhow!(\"Package `{package}` not found in workspace\"))?;\n\n        if !package.pyproject_toml().is_package(true) {\n            let name = &package.project().name;\n            let pyproject_toml = package.root().join(\"pyproject.toml\");\n            return Err(anyhow::anyhow!(\n                \"Package `{}` is missing a `{}`. For example, to build with `{}`, add the following to `{}`:\\n```toml\\n[build-system]\\nrequires = [\\\"uv_build>={min_version},<{max_version}\\\"]\\nbuild-backend = \\\"uv_build\\\"\\n```\",\n                name.cyan(),\n                \"build-system\".green(),\n                \"uv_build\".cyan(),\n                pyproject_toml.user_display().cyan()\n            ));\n        }\n\n        vec![AnnotatedSource::from(Source::Directory(Cow::Borrowed(\n            package.root(),\n        )))]\n    } else if all_packages {\n        if matches!(src, Source::File(_)) {","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/astral-sh/uv/blob/f1a42680ff5272232d65748acf338b19778dde24/crates/uv/src/commands/build_frontend.rs#L355-L391","documentation":"After `uv build --package <name>`, uv discovers the workspace rooted at the source directory and looks the name up in workspace.packages(). If no member (root package or tool.uv.workspace.members entry) carries that exact project name, this error fires. Lookup is exact-match on the normalized project name from each member's pyproject.toml.","triggerScenarios":"`uv build --package uv-cli` when the member is actually named `uv-cli` but you typed `uvcli` (or a renamed package after a version bump); the target package lives outside the discovered workspace's members list; running from a directory whose workspace root differs from the one containing the package.","commonSituations":"Package renamed recently and stale scripts use the old name; monorepo where the desired member is excluded from workspace.members; running from a subdirectory that resolves to a different workspace root than expected.","solutions":["List the actual member names (check each pyproject.toml `[project] name` under the workspace root) and correct the --package value.","Add the package's directory to `tool.uv.workspace.members` in the workspace root pyproject.toml if it is meant to be a member.","Run from (or pass `--directory`/`--project` pointing at) the correct workspace root so discovery finds the package.","Use the exact spelling/casing of the project name; avoid distribution-name vs import-name confusion."],"exampleFix":"# before\nuv build --package uvcli\n# after (member is named `uv-cli` in its pyproject.toml)\nuv build --package uv-cli","handlingStrategy":"validation","validationCode":"# Rust: verify membership before calling build\nlet workspace = Workspace::discover(src_dir, &DiscoveryOptions::default(), cache, ws_cache).await?;\nlet name = PackageName::from_str(package)?;\nif !workspace.packages().contains_key(&name) {\n    anyhow::bail!(\"{name} is not a workspace member; members: {:?}\",\n        workspace.packages().keys().collect::<Vec<_>>());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Derive --package values from each member's pyproject.toml `[project] name`, not from folder names.","After adding a package, confirm it appears in tool.uv.workspace.members glob matches.","Run builds from the workspace root (or pass --directory) so discovery is deterministic."],"tags":["build","workspace","package-selection"],"backgroundTag":null,"analyzedSha":"f1a42680ff5272232d65748acf338b19778dde24","analyzedAt":"2026-08-16T04:51:47.599Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}