{"record":{"id":"712418087ac7c433","repo":"astral-sh/uv","slug":"cannot-specify-all-packages-when-building-from","errorCode":null,"errorMessage":"Cannot specify `--all-packages` when building from a file","messagePattern":"Cannot specify `--all-packages` when building from a file","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/uv/src/commands/build_frontend.rs","lineNumber":392,"sourceCode":"\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(_)) {\n            return Err(anyhow::anyhow!(\n                \"Cannot specify `--all-packages` 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)\n                    .context(\"`--all-packages` was provided, but no workspace was found\");\n            }\n        };\n\n        if workspace.packages().is_empty() {\n            return Err(anyhow::anyhow!(\"No packages found in workspace\"));\n        }\n\n        let packages: Vec<_> = workspace\n            .packages()","sourceCodeStart":374,"sourceCodeEnd":410,"githubUrl":"https://github.com/astral-sh/uv/blob/f1a42680ff5272232d65748acf338b19778dde24/crates/uv/src/commands/build_frontend.rs#L374-L410","documentation":"`uv build --all-packages` iterates every buildable workspace member, which requires directory sources. If the resolved source is a file (sdist archive), uv rejects the flag immediately with this error — an archive contains exactly one package, so 'all packages' is meaningless there.","triggerScenarios":"`uv build --all-packages ./dist/mypkg-1.0.tar.gz`; --all-packages set persistently in config/env (UV_BUILD_ALL_PACKAGES) while the positional source is an archive; CI templates that always pass --all-packages reused for sdist rebuilds.","commonSituations":"A Makefile/script with a fixed flag set used for both workspace and single-artifact builds.","solutions":["Remove `--all-packages` (and any UV_BUILD_ALL_PACKAGES env/config) when the source is a file.","Or point the source at the workspace directory and keep --all-packages."],"exampleFix":"# before\nuv build --all-packages ./dist/mypkg-1.0.tar.gz\n# after\nuv build ./dist/mypkg-1.0.tar.gz      # or: uv build --all-packages .","handlingStrategy":"validation","validationCode":"# Shell: gate --all-packages on directory sources\nFLAGS=\"\"\n[ -d \"$SRC\" ] && FLAGS=\"--all-packages\"\nuv build $FLAGS \"$SRC\"","typeGuard":"fn supports_all_packages(src: &Source) -> bool {\n    matches!(src, Source::Directory(_))\n}","tryCatchPattern":null,"preventionTips":["Don't bake --all-packages into shared scripts that also handle single archives.","Unset UV_BUILD_ALL_PACKAGES in environments that rebuild sdists."],"tags":["build","cli-usage","package-selection"],"backgroundTag":null,"analyzedSha":"f1a42680ff5272232d65748acf338b19778dde24","analyzedAt":"2026-08-16T04:51:47.599Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}