{"record":{"id":"d11feca161cde9d0","repo":"anomalyco/sst","slug":"failed-to-read-source-directory-w","errorCode":null,"errorMessage":"failed to read source directory: %w","messagePattern":"failed to read source directory: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/runtime/python/build.go","lineNumber":1121,"sourceCode":"\t\t\t// Add workspace packages referenced via { workspace = true }\n\t\t\tfor name, source := range config.Tool.UV.Sources {\n\t\t\t\tif source.Workspace {\n\t\t\t\t\tpackages = append(packages, name)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn packages\n}\n\n// copyDependencyPackages copies installed dependency packages (not requirements.txt, etc.)\nfunc copyDependencyPackages(srcDir, destDir string) error {\n\tslog.Debug(\"copying dependency packages\", \"src\", srcDir)\n\n\tentries, err := os.ReadDir(srcDir)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to read source directory: %w\", err)\n\t}\n\n\tcopiedCount := 0\n\tcopiedFiles := 0\n\tcopiedPthPackages := 0\n\tfor _, entry := range entries {\n\t\tname := entry.Name()\n\n\t\t// Skip special directories and non-package files\n\t\tif strings.HasPrefix(name, \".\") {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Skip non-package files\n\t\tif name == \"requirements.txt\" || name == \"requirements-filtered.txt\" || name == \"resource.enc\" {\n\t\t\tcontinue\n\t\t}\n","sourceCodeStart":1103,"sourceCodeEnd":1139,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/pkg/runtime/python/build.go#L1103-L1139","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","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"],"exampleFix":"// before\n// install step failed silently, staging dir empty => failed to read source directory: open /project/.sst/.../site-packages: no such file or directory\n// after\nrm -rf .sst && sst deploy // forces uv sync + install to run before copyDependencyPackages","handlingStrategy":"validation","validationCode":"// Go: check the staging directory before copying\nif info, err := os.Stat(srcDir); err != nil || !info.IsDir() {\n    return fmt.Errorf(\"dependency staging dir %s missing; dependency install must run first\", srcDir)\n}","typeGuard":null,"tryCatchPattern":"if err := copyDependencyPackages(srcDir, destDir); err != nil {\n    var pe *fs.PathError\n    if errors.As(err, &pe) && errors.Is(pe.Err, fs.ErrNotExist) {\n        // staging dir absent: re-run uv sync/install before packaging\n    }\n    return err\n}","preventionTips":["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)"],"tags":["go","filesystem","python-runtime","packaging"],"backgroundTag":"directory-not-found","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}