matryer/xbar · error
rename existing app
Error message
rename existing app
What it means
os.Rename of the current app binary to '<appPath>.previous' failed and the app path still exists (the os.IsNotExist check on statErr failed), so the error is wrapped as 'rename existing app'. This means the old binary could not be moved aside before unarchiving the new version.
Source
Thrown at pkg/update/update.go:219
return errors.Wrap(err, "download asset")
}
f.Close()
executable, err := u.GetExecutable()
if err != nil {
return errors.Wrap(err, "get executable")
}
appPath, err := appPathFromExecutable(executable)
if err != nil {
return errors.Wrap(err, "find app path")
}
appPathDir := filepath.Dir(appPath)
appPreviousPath := appPath + ".previous"
err = os.Rename(appPath, appPreviousPath)
if err != nil {
_, statErr := os.Stat(appPath)
// not exist is ok, just ignore it
if !os.IsNotExist(statErr) {
return errors.Wrap(err, "rename existing app")
}
}
err = archiver.Unarchive(f.Name(), appPathDir)
if err != nil {
return errors.Wrap(err, "unarchive")
}
err = os.RemoveAll(appPreviousPath)
if err != nil {
return errors.Wrap(err, "remove previous")
}
return nil
}
// Release is a GitHub release.
type Release struct {
TagName string `json:"tag_name"`
Assets []Asset `json:"assets"`
Body string `json:"body"`View on GitHub (pinned to d624239058)
Solutions
- Ensure no other instance of the app or antivirus is holding the binary open, then retry.
- Verify write/create permissions on the directory containing the executable.
- On Windows, rename after the process exits (external updater) or use a move-and-restart helper.
- Check that appPath is a regular file on a filesystem supporting rename.
Defensive patterns
Strategy: try-catch
Validate before calling
appDir := filepath.Dir(appPath)
if fi, err := os.Stat(appDir); err != nil || !fi.IsDir() {
return fmt.Errorf("app dir missing: %v", err)
}
probe := filepath.Join(appDir, ".write-test")
if err := os.WriteFile(probe, nil, 0o644); err != nil {
return fmt.Errorf("app dir not writable: %w", err)
}
os.Remove(probe) Try / catch
err := u.Update()
if err != nil && strings.Contains(err.Error(), "rename existing app") {
if runtime.GOOS == "windows" {
return fmt.Errorf("close all app instances and retry: %w", err)
}
return err
} Prevention
- Ensure only one instance of the app runs during updates
- Whitelist the install dir in antivirus on Windows
- Install to a user-writable location, not read-only system paths
When it happens
Trigger: Calling Update() when the app file is locked by another process (Windows file locking), lives on a different filesystem than needed, or the app directory is not writable.
Common situations: Windows: the running exe is locked by antivirus or another instance; Unix: read-only mount or permission denied on the app directory; the appPath is a directory rather than a file.
Related errors
- create directory %s for plugin
- create plugin file %s
- set executable permission on plugin entry point
- ReadDir
- WriteFile
AI-assisted analysis of matryer/xbar@d624239058 (2026-09-02).
Data as JSON: /api/errors/85a08ec4c20e9a90.
Report an issue: GitHub.