wavetermdev/waveterm · error
failed to create destination directory: %w
Error message
failed to create destination directory: %w
What it means
After validating the destination path, RenameAppFile creates the destination's parent directory with os.MkdirAll before renaming. If that mkdir fails, the error is wrapped as "failed to create destination directory". This usually reflects filesystem-level problems (permissions, full disk, path conflicts) rather than bad input.
Source
Thrown at pkg/waveappstore/waveappstore.go:399
}
appDir, err := GetAppDir(appId)
if err != nil {
return err
}
fromPath, err := validateAndResolveFilePath(appDir, fromFileName)
if err != nil {
return fmt.Errorf("invalid source path: %w", err)
}
toPath, err := validateAndResolveFilePath(appDir, toFileName)
if err != nil {
return fmt.Errorf("invalid destination path: %w", err)
}
if err := os.MkdirAll(filepath.Dir(toPath), 0755); err != nil {
return fmt.Errorf("failed to create destination directory: %w", err)
}
if err := os.Rename(fromPath, toPath); err != nil {
return fmt.Errorf("failed to rename file: %w", err)
}
return nil
}
func FormatGoFile(appId string, fileName string) error {
if err := ValidateAppId(appId); err != nil {
return fmt.Errorf("invalid appId: %w", err)
}
appDir, err := GetAppDir(appId)
if err != nil {
return err
}View on GitHub (pinned to a4447c1563)
Solutions
- Check permissions on ~/waveapps/<ns>/<app> and its parent (need write + execute for the running user)
- Verify free disk space with df on the home-directory volume
- Check that no regular file exists at filepath.Dir(toPath) which blocks directory creation
- Run the app/terminal process as a user that owns the waveapps tree
Example fix
// shell check before retry ls -ld ~/waveapps/<ns>/<app> && df -h ~ // fix ownership sudo chown -R "$USER" ~/waveapps
Defensive patterns
Strategy: try-catch
Validate before calling
appDir, _ := GetAppDir(appId)
toPath := filepath.Join(appDir, filepath.Clean(toFileName))
parent := filepath.Dir(toPath)
if fi, err := os.Stat(parent); err == nil && !fi.IsDir() {
return errors.New("destination parent exists as a file")
}
if err := unix.Access(parent, unix.W_OK); err != nil {
return fmt.Errorf("no write access to %s: %w", parent, err) Try / catch
if err := RenameAppFile(appId, from, to); err != nil {
if strings.Contains(err.Error(), "failed to create destination directory") {
// surface as environment/permissions problem, not user input error
return fmt.Errorf("filesystem error creating dir for %q: %w", to, err)
}
return err
} Prevention
- Keep ~/waveapps owned and writable by the user running the app
- Monitor disk space on the home-directory volume
- Avoid renaming files into directories whose path collides with an existing file
When it happens
Trigger: os.MkdirAll(filepath.Dir(toPath), 0755) fails while renaming an app file into a new subdirectory — e.g. parent dir is read-only, disk is full, or a non-directory file exists at that path.
Common situations: ~/waveapps owned by another user or on a read-only mount; quota/disk-full on the volume holding the home directory; destination nested directory name colliding with an existing regular file.
Related errors
- failed to create backup directory: %w
- failed to create socket directory: %w
- failed to create log directory: %w
- failed to open log file: %w
- failed to read directory: %w
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/4e8e46d9bf45d5e7.
Report an issue: GitHub.