{"record":{"id":"d8c0db51da3765d7","repo":"anomalyco/sst","slug":"uv-build-failed-exit-code-d-s","errorCode":null,"errorMessage":"uv build failed (exit code %d): %s","messagePattern":"uv build failed \\(exit code (.+?)\\): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/runtime/python/build.go","lineNumber":1484,"sourceCode":"\n\targs = append(args, \"--no-sources\")\n\n\tworkingDir := cmd.PackageDir\n\tif workingDir == \"\" {\n\t\tworkingDir = \".\"\n\t}\n\n\tresult, err := runUvCommand(ctx, \"uv\", args, workingDir)\n\tif err != nil {\n\t\tslog.Error(\"UV build command failed\",\n\t\t\t\"package\", cmd.PackageName,\n\t\t\t\"command\", \"uv \"+strings.Join(args, \" \"),\n\t\t\t\"error\", err)\n\t\treturn fmt.Errorf(\"uv build failed: %w\", err)\n\t}\n\n\tif !result.Success {\n\t\treturn fmt.Errorf(\"uv build failed (exit code %d): %s\", result.ExitCode, result.Stderr)\n\t}\n\n\treturn nil\n}\n\n// runUvExport executes a UV export command\nfunc runUvExport(ctx context.Context, cmd *uvExportCommand) error {\n\targs := []string{\"export\"}\n\n\tif cmd.AllPackages {\n\t\targs = append(args, \"--all-packages\")\n\t} else if cmd.PackageName != \"\" {\n\t\targs = append(args, \"--package=\"+cmd.PackageName)\n\t}\n\n\tif cmd.OutputFile != \"\" {\n\t\targs = append(args, \"--output-file=\"+cmd.OutputFile)\n\t}","sourceCodeStart":1466,"sourceCodeEnd":1502,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/pkg/runtime/python/build.go#L1466-L1502","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before: uv build failed (exit code 1): error: Distribution ... does not have a `name`\n# after (pyproject.toml)\n[project]\nname = \"my-package\"\nversion = \"0.1.0\"\n\n[build-system]\nrequires = [\"hatchling\"]\nbuild-backend = \"hatchling.build\"","handlingStrategy":"try-catch","validationCode":"# validate the package before invoking the build\nuv build --help >/dev/null && cd packages/mypkg && uv build  # reproduce locally first\n# check pyproject.toml essentials\npython -c \"import tomllib; c=tomllib.load(open('pyproject.toml','rb')); assert c['project']['name']; assert c['build-system']['build-backend']\"","typeGuard":null,"tryCatchPattern":"if err := buildPackage(ctx, cmd); err != nil {\n    var exitErr *exec.ExitError\n    // or parse the \"uv build failed (exit code N)\" wrapper\n    if strings.Contains(err.Error(), \"uv build failed (exit code\") {\n        slog.Error(\"uv build rejected the package\", \"stderr\", err) // stderr carries root cause\n    }\n    return err\n}","preventionTips":["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"],"tags":["go","uv","python","build","exit-code"],"backgroundTag":"build-command-exit-nonzero","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}