anomalyco/sst · error
failed to copy workspace package %s: %w
Error message
failed to copy workspace package %s: %w
What it means
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.
Source
Thrown at pkg/runtime/python/build.go:720
data, readErr := os.ReadFile(srcPyproject)
if readErr != nil {
return fmt.Errorf("failed to read pyproject.toml for workspace package %s: %w", pkgPath, readErr)
}
if err := os.WriteFile(destPyproject, data, 0644); err != nil {
return fmt.Errorf("failed to copy pyproject.toml for workspace package %s: %w", pkgPath, err)
}
}
}
continue
}
if err := os.MkdirAll(filepath.Dir(destPath), 0755); err != nil {
return fmt.Errorf("failed to create directory for workspace package %s: %w", pkgPath, err)
}
// Preserve pyproject.toml and metadata for uv pip install
if err := copyDir(fullPath, destPath, skipBuildArtifacts); err != nil {
return fmt.Errorf("failed to copy workspace package %s: %w", pkgPath, err)
}
}
return nil
}
// copySourceFilesSimple copies handler source files to the build output.
// Workspace packages are installed via uv pip install separately.
func copySourceFilesSimple(input *runtime.BuildInput, projectInfo *projectInfo) error {
workspaceDir := projectInfo.SourceRoot
if projectInfo.PyprojectPath != "" {
workspaceDir = filepath.Dir(projectInfo.PyprojectPath)
}
handlerPath := input.Handler
// Strip workspace prefix from handler pathView on GitHub (pinned to a0bd20f762)
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.
Example fix
// before Error: failed to copy workspace package ./packages/core: lstat packages/core/.venv/lib: no such file or directory // after $ rm -rf .sst $ rm packages/core/.venv # or add build artifacts outside the package dir $ sst deploy
Defensive patterns
Strategy: validation
Validate before calling
// pre-deploy: ensure package dir has no dangling symlinks and is readable
fs.accessSync(pkgDir, fs.constants.R_OK);
for (const f of fs.readdirSync(pkgDir, { recursive: true })) {
try { fs.statSync(path.join(pkgDir, f)); } catch { throw new Error(`dangling entry in package: ${f}`); }
} Type guard
null
Try / catch
try {
await deploy();
} catch (e) {
if (/failed to copy workspace package/.test(e.message)) {
// stop watchers, clean, retry once
fs.rmSync('.sst', { recursive: true, force: true });
await deploy();
} else throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- failed to copy %s to %s: %w
- failed to copy pyproject.toml for workspace package %s: %w
- failed to create directory for workspace package %s: %w
- failed to copy directory %s: %w
- failed to copy file %s: %w
AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30).
Data as JSON: /api/errors/fee526390e55482f.
Report an issue: GitHub.