anomalyco/sst · error

UV export failed: %w

Error message

UV export failed: %w

What it means

runUvExport runs `uv export` (with flags like --no-dev when NoDev is set) from cmd.WorkspaceDir to produce a requirements.txt for the function. This error wraps an exec-level failure of the uv process. A non-zero exit code is handled separately via detailedExportError, which adds project-specific hints — so this error means uv could not be run at all.

Source

Thrown at pkg/runtime/python/build.go:1518

	if cmd.OutputFile != "" {
		args = append(args, "--output-file="+cmd.OutputFile)
	}
	if cmd.NoEmitWorkspace {
		args = append(args, "--no-emit-workspace")
	}
	if cmd.NoEditable {
		args = append(args, "--no-editable")
	}
	if cmd.NoEmitProject {
		args = append(args, "--no-emit-project")
	}
	if cmd.NoDev {
		args = append(args, "--no-dev")
	}

	result, err := runUvCommand(ctx, "uv", args, cmd.WorkspaceDir)
	if err != nil {
		return fmt.Errorf("UV export failed: %w", err)
	}

	if !result.Success {
		return detailedExportError(result, cmd)
	}

	return nil
}

// detailedExportError creates a detailed error message for export failures
func detailedExportError(result *commandResult, cmd *uvExportCommand) error {
	errorMsg := fmt.Sprintf("UV export failed with exit code %d", result.ExitCode)

	if cmd.PackageName != "" {
		errorMsg += fmt.Sprintf(" (exporting package: %s)", cmd.PackageName)
	}
	if cmd.OutputFile != "" {
		errorMsg += fmt.Sprintf(" to file: %s", cmd.OutputFile)

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Install uv and ensure `uv --version` succeeds from the same environment that runs sst deploy
  2. Verify cmd.WorkspaceDir exists and contains uv.lock/pyproject.toml (cd into it and run `uv export` manually to reproduce)
  3. Check PATH for the process executing the build (CI containers often have a minimal PATH; export the uv install dir)
  4. Read the wrapped %w error for the exact OS-level cause (file not found vs permission denied)
  5. If this appears after a toolchain/manager change (asdf, mise, pyenv), re-shim/reinstall uv for that environment

Example fix

// before (local dev, uv installed via ~/.local/bin not on CI PATH)
=> UV export failed: exec: "uv": executable file not found in $PATH
// after (CI workflow)
- run: curl -LsSf https://astral.sh/uv/install.sh | sh
- run: echo "$HOME/.local/bin" >> $GITHUB_PATH
Defensive patterns

Strategy: validation

Validate before calling

# verify uv and the workspace before running sst deploy
if ! command -v uv >/dev/null 2>&1; then
  echo "uv not found on PATH"; exit 1
fi
cd "$WORKSPACE_DIR" && test -f uv.lock && uv export --dry-run >/dev/null

Try / catch

if err := generateOrCopyRequirementsFile(ctx, cmd); err != nil {
    if strings.Contains(err.Error(), `executable file not found in $PATH`) {
        // uv missing: print install instructions
    }
    return err
}

Prevention

When it happens

Trigger: generateOrCopyRequirementsFile calls runUvExport and runUvCommand returns an error: the uv binary is missing/not on PATH, the workspace directory (cmd.WorkspaceDir) does not exist or is unreadable, or process spawn failed (permissions, resource limits).

Common situations: uv not installed in the CI image or dev container; uv.lock present but uv unavailable; WorkspaceDir pointing at a renamed/missing directory in a monorepo; PATH differences between the user's shell and the process running sst deploy.

Related errors


AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30). Data as JSON: /api/errors/b74d4653bd5e2181. Report an issue: GitHub.