anomalyco/sst · error

failed to copy workspace packages for container: %w

Error message

failed to copy workspace packages for container: %w

What it means

For container builds, installDependenciesForLambda copies workspace-local Python packages (sibling packages in the monorepo/workspace) next to the function so the Dockerfile can install them. This error means one of those package copies failed, before Docker ever runs.

Source

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

// parseInputProperties parses the input properties JSON
func parseInputProperties(input *runtime.BuildInput) (*inputProperties, error) {
	var props inputProperties
	if err := json.Unmarshal(input.Properties, &props); err != nil {
		return nil, fmt.Errorf("failed to parse properties: %w", err)
	}

	return &props, nil
}

func installDependenciesForLambda(ctx context.Context, input *runtime.BuildInput, projectInfo *projectInfo, architecture string) error {
	if err := copySourceFilesSimple(input, projectInfo); err != nil {
		return fmt.Errorf("failed to copy source files: %w", err)
	}

	// Container builds: Dockerfile handles deps; zip builds: install here
	if input.IsContainer {
		if err := copyWorkspacePackagesForContainer(input, projectInfo); err != nil {
			return fmt.Errorf("failed to copy workspace packages for container: %w", err)
		}
	} else {
		if err := copySyncedDependencies(ctx, input, projectInfo, architecture); err != nil {
			return fmt.Errorf("failed to copy synced dependencies: %w", err)
		}
	}

	return nil
}

// copyWorkspacePackagesForContainer copies workspace package directories into the artifact
// so the Dockerfile's `uv pip install -r requirements.txt` can resolve relative paths.
func copyWorkspacePackagesForContainer(input *runtime.BuildInput, projectInfo *projectInfo) error {
	workspaceRoot := findWorkspaceRoot(projectInfo)

	requirementsPath := filepath.Join(input.Out(), "requirements.txt")
	content, err := os.ReadFile(requirementsPath)
	if err != nil {

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Confirm every workspace package path in your project config exists on disk (ls each path from the error message)
  2. Update the function's dependency references after any package rename/move
  3. Fix permissions on the workspace package directory (chmod -R u+rX)
  4. Clear stale build state (.sst) and rebuild so the workspace list is recomputed

Example fix

// before (sst.config.ts — package renamed but dependency path stale)
"dependencies": ["../packages/shared"]  // packages/shared no longer exists
// after
ls packages/
"dependencies": ["../packages/shared-py"]
Defensive patterns

Strategy: validation

Validate before calling

for _, dep := range workspaceDeps { // e.g. "../packages/shared"
	full := filepath.Join(projectRoot, dep)
	if fi, err := os.Stat(full); err != nil || !fi.IsDir() {
		log.Fatalf("workspace package %s missing — update config after renames", full)
	}
	if unix.Access(full, unix.R_OK) != nil {
		log.Fatalf("workspace package %s not readable", full)
	}
}

Try / catch

if err := deploy(); err != nil && strings.Contains(err.Error(), "failed to copy workspace packages for container") {
	fmt.Println("verify each workspace package path exists and is readable; rm -rf .sst to clear stale workspace lists")
	os.Exit(1)
}

Prevention

When it happens

Trigger: copyWorkspacePackagesForContainer fails while reading or copying a workspace package's files: the package path listed in the workspace config doesn't exist, its files are unreadable, or the destination in the build output can't be written.

Common situations: Monorepo where a package referenced as a workspace dependency was moved/renamed or deleted; a workspace package with restrictive file permissions; stale cached workspace listing pointing at an old path after a refactor.

Related errors


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