anomalyco/sst · error
failed to read source directory: %w
Error message
failed to read source directory: %w
What it means
copyDependencyPackages copies installed site-packages (excluding requirements.txt and other non-package files) from the uv/pip staging directory into the function bundle. It wraps the error from os.ReadDir(srcDir), meaning the staged dependency source directory could not be read. This is thrown before any copying begins, so the resulting Lambda bundle would be missing all dependencies.
Source
Thrown at pkg/runtime/python/build.go:1121
// Add workspace packages referenced via { workspace = true }
for name, source := range config.Tool.UV.Sources {
if source.Workspace {
packages = append(packages, name)
}
}
}
}
return packages
}
// copyDependencyPackages copies installed dependency packages (not requirements.txt, etc.)
func copyDependencyPackages(srcDir, destDir string) error {
slog.Debug("copying dependency packages", "src", srcDir)
entries, err := os.ReadDir(srcDir)
if err != nil {
return fmt.Errorf("failed to read source directory: %w", err)
}
copiedCount := 0
copiedFiles := 0
copiedPthPackages := 0
for _, entry := range entries {
name := entry.Name()
// Skip special directories and non-package files
if strings.HasPrefix(name, ".") {
continue
}
// Skip non-package files
if name == "requirements.txt" || name == "requirements-filtered.txt" || name == "resource.enc" {
continue
}
View on GitHub (pinned to a0bd20f762)
Solutions
- Verify the dependency install step (uv sync / uv pip install) ran successfully before packaging — inspect earlier build logs for install failures
- Delete stale build output (.sst) and redeploy so the staging directory is recreated
- Check permissions on the staging directory and that the path exists (ls the path from the error's wrapped message)
- Avoid running concurrent builds into the same output directory
Example fix
// before // install step failed silently, staging dir empty => failed to read source directory: open /project/.sst/.../site-packages: no such file or directory // after rm -rf .sst && sst deploy // forces uv sync + install to run before copyDependencyPackages
Defensive patterns
Strategy: validation
Validate before calling
// Go: check the staging directory before copying
if info, err := os.Stat(srcDir); err != nil || !info.IsDir() {
return fmt.Errorf("dependency staging dir %s missing; dependency install must run first", srcDir)
} Try / catch
if err := copyDependencyPackages(srcDir, destDir); err != nil {
var pe *fs.PathError
if errors.As(err, &pe) && errors.Is(pe.Err, fs.ErrNotExist) {
// staging dir absent: re-run uv sync/install before packaging
}
return err
} Prevention
- Ensure the uv/pip install step completes and logs its output dir before packaging
- Clear stale .sst build output when switching branches or dependency managers
- Don't share one build output dir across concurrent builds
- Verify the process user has read access to the staging directory (CI container users)
When it happens
Trigger: copySyncedDependencies calls copyDependencyPackages(srcDir, destDir) where srcDir (the installed-packages output of the uv sync/export + install step) does not exist or is unreadable — e.g. the install step silently failed, an empty/overridden build output dir, or permission issues on the staging path.
Common situations: uv install skipped or failed earlier but its error was not surfaced; custom build output directory misconfigured; the staging dir removed by a parallel build; working on a read-only or restricted filesystem (CI container user mismatch).
Related errors
- error walking target directory during cleanup: %w
- failed to flatten %s structure: %w
- failed to open archive: %w
- failed to remove old directory: %w
- failed to move src directory contents: %w
AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30).
Data as JSON: /api/errors/d11feca161cde9d0.
Report an issue: GitHub.