anomalyco/sst · error
failed to copy source files: %w
Error message
failed to copy source files: %w
What it means
installDependenciesForLambda first copies the function's source files into the build output via copySourceFilesSimple. If that copy step fails, nothing else proceeds and the error is wrapped here. It indicates the source tree could not be read or the destination could not be written.
Source
Thrown at pkg/runtime/python/build.go:639
// inputProperties represents the input properties structure
type inputProperties struct {
Architecture string `json:"architecture"`
}
// 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.View on GitHub (pinned to a0bd20f762)
Solutions
- Verify the srcPath in your sst config exists relative to the project root and contains your Python entry files
- Fix read permissions on source files and write permissions on the build output (chmod -R u+rw)
- Run from the project root (or set the correct root) so relative paths resolve
- Check the wrapped inner error for the exact file that failed and correct/remove it
Example fix
// before (sst.config.ts)
new sst.aws.PythonFunction("Fn", { srcPath: "services/api-py" })
// error: failed to copy source files (dir renamed)
// after
ls services/api-python # actual dir
new sst.aws.PythonFunction("Fn", { srcPath: "services/api-python" }) Defensive patterns
Strategy: validation
Validate before calling
srcPath := "services/api-python" // from sst.config.ts
if fi, err := os.Stat(srcPath); err != nil || !fi.IsDir() {
log.Fatalf("srcPath %q does not exist — fix sst.config.ts", srcPath)
}
if _, err := os.Stat(filepath.Join(srcPath, "<handler>.py")); err != nil {
log.Fatalf("handler file missing in %s", srcPath)
} Try / catch
if err := deploy(); err != nil && strings.Contains(err.Error(), "failed to copy source files") {
fmt.Println("check srcPath in sst.config.ts exists and contains your .py files; check file permissions")
os.Exit(1)
} Prevention
- Keep srcPath in sync with actual directory names (update config on renames)
- Run sst commands from the project root so relative paths resolve
- Ensure source files are readable by the build user in CI containers
- Don't gitignore/delete files the function depends on
When it happens
Trigger: copySourceFilesSimple fails: the configured source directory doesn't exist or has a wrong srcPath in the sst config, unreadable source files (permissions), or unwritable/full build output.
Common situations: Typo'd or moved path in the sst config (function's srcPath points to a deleted/renamed folder); .gitignore-style excludes hiding everything; running the build in a container/CI that mounted the repo at a different path; restrictive file modes from an extracted archive.
Related errors
- failed to create output directory: %w
- failed to copy %s to %s: %w
- failed to move extracted package: %w
- failed to open archive: %w
- failed to copy synced dependencies: %w
AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30).
Data as JSON: /api/errors/21dcb79fe2d17b64.
Report an issue: GitHub.