anomalyco/sst · error
uv build failed (exit code %d): %s
Error message
uv build failed (exit code %d): %s
What it means
runUvBuild ran `uv build` successfully as a process but it exited with a non-zero code. The error embeds the exit code and uv's stderr, which normally contains the real reason (invalid pyproject.toml, missing build backend, compile error in the package, locked dependency conflicts). This is the structured-failure path as opposed to the process-spawn failure (uv build failed: %w).
Source
Thrown at pkg/runtime/python/build.go:1484
args = append(args, "--no-sources")
workingDir := cmd.PackageDir
if workingDir == "" {
workingDir = "."
}
result, err := runUvCommand(ctx, "uv", args, workingDir)
if err != nil {
slog.Error("UV build command failed",
"package", cmd.PackageName,
"command", "uv "+strings.Join(args, " "),
"error", err)
return fmt.Errorf("uv build failed: %w", err)
}
if !result.Success {
return fmt.Errorf("uv build failed (exit code %d): %s", result.ExitCode, result.Stderr)
}
return nil
}
// runUvExport executes a UV export command
func runUvExport(ctx context.Context, cmd *uvExportCommand) error {
args := []string{"export"}
if cmd.AllPackages {
args = append(args, "--all-packages")
} else if cmd.PackageName != "" {
args = append(args, "--package="+cmd.PackageName)
}
if cmd.OutputFile != "" {
args = append(args, "--output-file="+cmd.OutputFile)
}View on GitHub (pinned to a0bd20f762)
Solutions
- Read the %s stderr portion of the error — it contains uv's actual complaint; fix that first
- Ensure pyproject.toml has a valid [build-system] with an installable backend and correct project name/version
- Run `uv build` manually in the package directory to iterate quickly on the failure
- If the backend or toolchain is missing (gcc/rust for native deps), install it or pin a pure-Python build backend
- Check requires-python matches the Python version available to uv
Example fix
# before: uv build failed (exit code 1): error: Distribution ... does not have a `name` # after (pyproject.toml) [project] name = "my-package" version = "0.1.0" [build-system] requires = ["hatchling"] build-backend = "hatchling.build"
Defensive patterns
Strategy: try-catch
Validate before calling
# validate the package before invoking the build
uv build --help >/dev/null && cd packages/mypkg && uv build # reproduce locally first
# check pyproject.toml essentials
python -c "import tomllib; c=tomllib.load(open('pyproject.toml','rb')); assert c['project']['name']; assert c['build-system']['build-backend']" Try / catch
if err := buildPackage(ctx, cmd); err != nil {
var exitErr *exec.ExitError
// or parse the "uv build failed (exit code N)" wrapper
if strings.Contains(err.Error(), "uv build failed (exit code") {
slog.Error("uv build rejected the package", "stderr", err) // stderr carries root cause
}
return err
} Prevention
- Include a correct [build-system] table (e.g. hatchling or setuptools) in every workspace package pyproject.toml
- Fill in project name and version in pyproject.toml
- Commit uv.lock and pin build requirements for reproducible CI builds
- Install native toolchains (gcc/rust) when the package has compiled extensions
- Match requires-python to the Python version used by uv
When it happens
Trigger: buildPackage calls runUvBuild for a workspace package; uv runs but exits non-zero because the package's pyproject.toml is invalid, the declared build backend (setuptools/hatchling/maturin) is missing or fails, source files have syntax/import errors, or the build environment cannot resolve build requirements.
Common situations: Missing [build-system] table in pyproject.toml; hatchling/setuptools not resolvable in a pinned/offline CI environment; package name/version fields missing or malformed; native extension build toolchain (gcc, rust) absent; Python version mismatch declared via requires-python.
Related errors
- uv build failed: %w
- uv pip install timed out after 15 minutes - check network co
- failed to run uv pip install: %v %s Function: %s Handler: %
- UV export failed: %w
- %s
AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30).
Data as JSON: /api/errors/d8c0db51da3765d7.
Report an issue: GitHub.