anomalyco/sst · error
failed to copy %s to %s: %w
Error message
failed to copy %s to %s: %w
What it means
flattenPackageToRoot iterates every file found in the extracted package and copies it to the flat output directory with copyFile. Any per-file copy failure (missing source, unreadable file, missing destination directory, permission error) is wrapped with both source and destination paths so the offending file is identifiable.
Source
Thrown at pkg/runtime/python/build.go:537
return nil
})
if err != nil {
return fmt.Errorf("failed to walk extracted directory: %w", err)
}
// Create output directory
if err := os.MkdirAll(outputDir, 0755); err != nil {
return fmt.Errorf("failed to create output directory: %w", err)
}
for _, srcFile := range pythonFiles {
relPath, _ := filepath.Rel(extractedDir, srcFile)
destFile := filepath.Join(outputDir, relPath)
if err := copyFile(srcFile, destFile); err != nil {
return fmt.Errorf("failed to copy %s to %s: %w", srcFile, destFile, err)
}
}
// Clean up the extracted directory
os.RemoveAll(extractedDir)
return nil
}
func installDependenciesForBuild(ctx context.Context, input *runtime.BuildInput, projectInfo *projectInfo) error {
if err := os.MkdirAll(input.Out(), 0755); err != nil {
return fmt.Errorf("failed to create output directory: %w", err)
}
requirementsFile := filepath.Join(input.Out(), "requirements.txt")
if err := generateOrCopyRequirementsFile(ctx, projectInfo, requirementsFile); err != nil {
return fmt.Errorf("failed to generate requirements file: %w", err)
}View on GitHub (pinned to a0bd20f762)
Solutions
- Run the build again — transient issues (deleted temp files, races with other builds) often resolve; avoid running concurrent builds into the same output dir
- Inspect the srcFile/destFile paths in the message and check permissions and existence of the file and its destination parent directory
- Free disk space (ENOSPC shows up as copy failures)
- If a specific archive file is consistently failing, reinstall/refresh the dependency or remove a broken symlink before building
Example fix
// before
if err := copyFile(srcFile, destFile); err != nil {
return fmt.Errorf("failed to copy %s to %s: %w", srcFile, destFile, err)
}
// after (ensure destination dir exists first)
os.MkdirAll(filepath.Dir(destFile), 0755)
if err := copyFile(srcFile, destFile); err != nil {
return fmt.Errorf("failed to copy %s to %s: %w", srcFile, destFile, err)
} Defensive patterns
Strategy: try-catch
Validate before calling
for _, f := range filesToCopy {
if fi, err := os.Lstat(f); err != nil || !fi.Mode().IsRegular() {
// skip or fix broken symlinks / unreadable files before copying
}
}
dfOut, _ := exec.Command("df", "-h", outputDir).Output() // ensure free space Type guard
func isRegularReadable(path string) bool {
fi, err := os.Stat(path)
return err == nil && fi.Mode().IsRegular() && unix.Access(path, unix.R_OK) == nil
} Try / catch
err := buildPython()
var pe *fs.PathError
switch {
case errors.As(err, &pe) && errors.Is(pe.Err, syscall.ENOSPC):
freeDiskAndRetry()
case errors.As(err, &pe) && errors.Is(pe.Err, syscall.EACCES):
fixPerms(pe.Path)
} Prevention
- Avoid running concurrent builds into the same output directory
- Refresh/reinstall dependencies whose archives contain symlinks that may dangle
- Keep free disk headroom for site-packages-sized copies
- Check permissions of files extracted from archives (umask) before copying
When it happens
Trigger: copyFile(srcFile, destFile) fails: srcFile disappeared or is unreadable (permissions, broken symlink), destFile's parent directory wasn't created, or the destination filesystem is full/read-only.
Common situations: A file inside the extracted wheel/archive is a dangling symlink or has restrictive modes; nested subdirectories whose parent dirs were never MkdirAll'd before copy; ENOSPC when copying a large dependency tree into the build output.
Related errors
- failed to create output directory: %w
- failed to copy source files: %w
- failed to copy directory %s: %w
- failed to copy file %s: %w
- failed to move extracted package: %w
AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30).
Data as JSON: /api/errors/a53fffe3b757fb49.
Report an issue: GitHub.