siyuan-note/siyuan · error
move [ ] to [ ] failed
Error message
move [%s] to [%s] failed: %w
What it means
This is the primary failure of the legacy iOS workspace migration: moving one known legacy directory (e.g. 'data', 'conf', 'temp') into the new default workspace with os.Rename failed. All completed moves are rolled back and the whole operation reports false, with this error as the head of the joined error chain. It means the workspace layout was left (or restored to) its legacy state.
Solutions
- Inspect the wrapped renameErr (%w): ENOENT means the source vanished (let sync settle and restart), EEXIST/ENOTEMPTY means the destination appeared (remove or merge it), EACCES/EPERM means fix permissions
- Ensure no other SiYuan instance or sync client is writing to the workspace, then restart the app so migration re-runs atomically
- Free disk space and verify the source and destination are on the same volume if EXDEV/ENOSPC is reported
- As a last resort, manually move the listed directory from the legacy location into the default workspace and restart
Example fix
// before: destination check and rename are not atomic, so a racing creator causes failure
if _, statErr := os.Lstat(to); statErr == nil {
return false, fmt.Errorf("destination [%s] already exists", to)
}
...
if renameErr := os.Rename(move.from, move.to); renameErr != nil {
// after: tolerate the destination already being moved (rename over empty dir succeeds) and re-check error kind
if renameErr := os.Rename(move.from, move.to); renameErr != nil {
if errors.Is(renameErr, os.ErrNotExist) {
logging.LogWarnf("legacy dir [%s] already gone, skipping", move.from)
continue
}
return false, fmt.Errorf("move [%s] to [%s] failed: %w", move.from, move.to, renameErr)
} Defensive patterns
Strategy: retry
Validate before calling
for _, name := range knownEntries {
from := filepath.Join(legacyWorkspaceDir, name)
to := filepath.Join(defaultWorkspaceDir, name)
if _, err := os.Lstat(to); err == nil {
return fmt.Errorf("destination [%s] already exists; resolve before migration", to)
}
if _, err := os.Lstat(from); errors.Is(err, fs.ErrNotExist) {
return fmt.Errorf("source [%s] missing; let sync settle before migration", from)
}
} Type guard
func isRenameFailure(err error) (src, dst string, ok bool) {
msg := err.Error()
if strings.HasPrefix(msg, "move [") {
parts := strings.Split(msg, "[")
if len(parts) >= 3 {
return strings.TrimSuffix(parts[1], "]"), strings.TrimSuffix(strings.SplitN(parts[2], "]", 2)[0], ""), true
}
}
return "", "", false
} Try / catch
if moved, err := migrateLegacyIOSWorkspace(...); err != nil {
if errors.Is(err, os.ErrPermission) || errors.Is(err, syscall.EBUSY) {
time.Sleep(retryDelay)
moved, err = migrateLegacyIOSWorkspace(...)
}
if err != nil {
logging.LogErrorf("workspace migration failed, legacy layout preserved: %v", err)
return err
}
} Prevention
- Quit all SiYuan instances and sync clients before upgrading across versions that change workspace layout
- Do not create files at the new workspace's expected entry names (data, conf, temp) before first launch
- Retry startup after transient failures — the rollback keeps the legacy layout intact for a clean retry
- Verify same-volume locations and sufficient free space for both source and destination directories
When it happens
Trigger: initWorkspaceDirMobile detects a legacy iOS workspace layout and migrateLegacyIOSWorkspace's os.Rename(from, to) returns an error — source missing, destination created between the Lstat check and the rename, cross-device rename not possible, or permission/EBUSY on either path.
Common situations: Upgrade across SiYuan versions that changed the workspace layout; a TOCTOU race where the new workspace directory got populated by another process between existence check and rename; source directory deleted or locked by cloud sync restoring files; volume or app-container permission issues on iOS.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- rollback [ ] to [ ] failed
- stat destination [ ] failed
- destination [ ] is not empty
- read destination [ ] failed
- stat source [ ] failed
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/c8518aa3702cf95a.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/util/working_mobile.go:204
return false, fmt.Errorf("destination [%s] already exists", to)
} else if !errors.Is(statErr, fs.ErrNotExist) {
return false, fmt.Errorf("stat destination [%s] failed: %w", to, statErr)
}
moves = append(moves, workspaceDirMove{from: from, to: to})
}
var completed []workspaceDirMove
for _, move := range moves {
if renameErr := os.Rename(move.from, move.to); renameErr != nil {
var rollbackErrors []error
for i := len(completed) - 1; 0 <= i; i-- {
completedMove := completed[i]
if rollbackErr := os.Rename(completedMove.to, completedMove.from); rollbackErr != nil {
rollbackErrors = append(rollbackErrors, fmt.Errorf("rollback [%s] to [%s] failed: %w",
completedMove.to, completedMove.from, rollbackErr))
}
}
return false, errors.Join(append([]error{fmt.Errorf("move [%s] to [%s] failed: %w", move.from, move.to, renameErr)}, rollbackErrors...)...)
}
completed = append(completed, move)
}
for _, move := range completed {
logging.LogInfof("moved legacy iOS workspace dir [from=%s, to=%s]", move.from, move.to)
}
return true, nil
}
func replaceLegacyIOSWorkspacePath(workspacePaths []string, workspaceBaseDir, defaultWorkspaceDir string) []string {
for i, workspacePath := range workspacePaths {
if filepath.Clean(workspacePath) == filepath.Clean(workspaceBaseDir) {
workspacePaths[i] = defaultWorkspaceDir
}
}
return DeduplicateWorkspacePaths(workspacePaths)
}View on GitHub (pinned to 9f775e8a12)