astral-sh/uv · error
Cannot specify `--all-packages` when building from a file
Error message
Cannot specify `--all-packages` when building from a file
What it means
`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.
Source
Thrown at crates/uv/src/commands/build_frontend.rs:392
if !package.pyproject_toml().is_package(true) {
let name = &package.project().name;
let pyproject_toml = package.root().join("pyproject.toml");
return Err(anyhow::anyhow!(
"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```",
name.cyan(),
"build-system".green(),
"uv_build".cyan(),
pyproject_toml.user_display().cyan()
));
}
vec![AnnotatedSource::from(Source::Directory(Cow::Borrowed(
package.root(),
)))]
} else if all_packages {
if matches!(src, Source::File(_)) {
return Err(anyhow::anyhow!(
"Cannot specify `--all-packages` when building from a file"
));
}
let workspace = match workspace {
Ok(ref workspace) => workspace,
Err(err) => {
return Err(err)
.context("`--all-packages` was provided, but no workspace was found");
}
};
if workspace.packages().is_empty() {
return Err(anyhow::anyhow!("No packages found in workspace"));
}
let packages: Vec<_> = workspace
.packages()View on GitHub (pinned to f1a42680ff)
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.
Example fix
# before uv build --all-packages ./dist/mypkg-1.0.tar.gz # after uv build ./dist/mypkg-1.0.tar.gz # or: uv build --all-packages .
Defensive patterns
Strategy: validation
Validate before calling
# Shell: gate --all-packages on directory sources FLAGS="" [ -d "$SRC" ] && FLAGS="--all-packages" uv build $FLAGS "$SRC"
Type guard
fn supports_all_packages(src: &Source) -> bool {
matches!(src, Source::Directory(_))
} Prevention
- Don't bake --all-packages into shared scripts that also handle single archives.
- Unset UV_BUILD_ALL_PACKAGES in environments that rebuild sdists.
When it happens
Trigger: `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.
Common situations: A Makefile/script with a fixed flag set used for both workspace and single-artifact builds.
Related errors
- Cannot specify `--package` when building from a file
- Package `{package}` not found in workspace
- Package `{}` is missing a `{}`. For example, to build with `
- Pass `--wheel` explicitly to build a wheel from a source dis
- Building an `--sdist` from a source distribution is not supp
AI-assisted analysis of astral-sh/uv@f1a42680ff (2026-08-16).
Data as JSON: /api/errors/712418087ac7c433.
Report an issue: GitHub.