{"record":{"id":"fee526390e55482f","repo":"anomalyco/sst","slug":"failed-to-copy-workspace-package-s-w","errorCode":null,"errorMessage":"failed to copy workspace package %s: %w","messagePattern":"failed to copy workspace package (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/runtime/python/build.go","lineNumber":720,"sourceCode":"\t\t\t\t\tdata, readErr := os.ReadFile(srcPyproject)\n\t\t\t\t\tif readErr != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"failed to read pyproject.toml for workspace package %s: %w\", pkgPath, readErr)\n\t\t\t\t\t}\n\t\t\t\t\tif err := os.WriteFile(destPyproject, data, 0644); err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"failed to copy pyproject.toml for workspace package %s: %w\", pkgPath, err)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tif err := os.MkdirAll(filepath.Dir(destPath), 0755); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to create directory for workspace package %s: %w\", pkgPath, err)\n\t\t}\n\n\t\t// Preserve pyproject.toml and metadata for uv pip install\n\t\tif err := copyDir(fullPath, destPath, skipBuildArtifacts); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to copy workspace package %s: %w\", pkgPath, err)\n\t\t}\n\n\t}\n\n\treturn nil\n}\n\n// copySourceFilesSimple copies handler source files to the build output.\n// Workspace packages are installed via uv pip install separately.\nfunc copySourceFilesSimple(input *runtime.BuildInput, projectInfo *projectInfo) error {\n\tworkspaceDir := projectInfo.SourceRoot\n\tif projectInfo.PyprojectPath != \"\" {\n\t\tworkspaceDir = filepath.Dir(projectInfo.PyprojectPath)\n\t}\n\n\thandlerPath := input.Handler\n\n\t// Strip workspace prefix from handler path","sourceCodeStart":702,"sourceCodeEnd":738,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/pkg/runtime/python/build.go#L702-L738","documentation":"During a container build, SST recursively copies each workspace package directory from the workspace root into the build output so the Dockerfile's `uv pip install -r requirements.txt` can resolve the relative path. This error is returned when copyDir (with build artifacts skipped) fails on any file within the package. The wrapped error identifies the specific file or subdirectory that could not be copied.","triggerScenarios":"copyDir(fullPath, destPath, skipBuildArtifacts) fails in copyWorkspacePackagesForContainer — e.g. a file inside the workspace package was deleted mid-build, a symlink points outside the workspace and is broken, or a nested destination file is unwritable.","commonSituations":"Watching dev process concurrently mutating package files during deploy; symlinks (e.g. node_modules-style or venv links) inside the package; stale output from a previous interrupted build; disk full while copying a large package.","solutions":["Read the wrapped error to find the failing file; fix it (recreate missing file, remove dangling symlink) and redeploy.","Clean the build output (`rm -rf .sst`) to eliminate conflicts with stale artifacts.","Avoid running deploy while editors/watchers are actively rewriting files in the workspace package.","Free disk space if the wrapped error is ENOSPC."],"exampleFix":"// before\nError: failed to copy workspace package ./packages/core: lstat packages/core/.venv/lib: no such file or directory\n// after\n$ rm -rf .sst\n$ rm packages/core/.venv   # or add build artifacts outside the package dir\n$ sst deploy","handlingStrategy":"validation","validationCode":"// pre-deploy: ensure package dir has no dangling symlinks and is readable\nfs.accessSync(pkgDir, fs.constants.R_OK);\nfor (const f of fs.readdirSync(pkgDir, { recursive: true })) {\n  try { fs.statSync(path.join(pkgDir, f)); } catch { throw new Error(`dangling entry in package: ${f}`); }\n}","typeGuard":"null","tryCatchPattern":"try {\n  await deploy();\n} catch (e) {\n  if (/failed to copy workspace package/.test(e.message)) {\n    // stop watchers, clean, retry once\n    fs.rmSync('.sst', { recursive: true, force: true });\n    await deploy();\n  } else throw e;\n}","preventionTips":["Keep virtualenvs/build artifacts out of workspace package directories","Don't edit files in the package while a deploy is running","Replace dangling symlinks or exclude them from the package","Ensure adequate free disk space before large deploys"],"tags":["filesystem","python","container-build","copy"],"backgroundTag":"file-copy-failed","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}