siyuan-note/siyuan · error
remove community package
Error message
remove community package [%s] failed
What it means
UninstallPackage deletes the package directory with os.RemoveAll under the install lock. If removal fails for any reason, it logs the cause and returns an error identifying the package by its base directory name.
Solutions
- Close applications holding files in the package directory (other SiYuan instances, editors, AV scans) and retry uninstall
- Check and fix permissions/ownership on the package directory
- Restart the SiYuan kernel to release in-process handles, then uninstall
- Manually remove the directory if the filesystem permits, then refresh the marketplace UI
Example fix
// before: uninstall fails while another Electron window holds the plugin open // after: close the extra SiYuan window (or restart the app), then Settings - Marketplace - Uninstall
Defensive patterns
Strategy: try-catch
Validate before calling
if _, err := os.Stat(installPath); err != nil { return nil } // nothing to uninstall
// best-effort writability probe
f, err := os.CreateTemp(installPath, ".probe*")
if err != nil { return fmt.Errorf("package dir not writable: %w", err) }
f.Close(); os.Remove(f.Name()) Try / catch
if err := UninstallPackage(installPath); err != nil {
base := filepath.Base(installPath)
// likely locked on Windows or permission-denied: ask user to close apps,
// then retry once before surfacing a manual-removal instruction
retry(func() error { return UninstallPackage(installPath) }, 1)
} Prevention
- Close other SiYuan instances/editors before uninstalling packages
- Exclude the data directory from AV real-time scanning and file-sync tools
- Keep package directories owned by the user running the kernel
- If removal keeps failing, delete the directory manually and refresh the marketplace
When it happens
Trigger: os.RemoveAll fails on the package install path — typically permission errors on Windows (file locked by another process) or read-only filesystems.
Common situations: Package files locked by antivirus, editors, or another running SiYuan/Electron instance on Windows; directory made read-only by sync tools; network-mounted data dir temporarily unavailable; root-owned files after manual edits.
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
- Uninstall failed
- Conf.Language(14) (copy resource failed: )
- create AI editor actions directory failed
- create conf dir failed
- create import dir failed:
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/04e132ab27047b78.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/bazaar/install.go:275
}
RemoveInstalledPackageSizeCache(pkgType, packageName)
now := time.Now()
recordPackageOperationTime(pkgType, packageName, now, fallbackInstallTime, update, "", "")
if chtimesErr := os.Chtimes(installPath, now, now); chtimesErr != nil {
logging.LogWarnf("set package [%s] folder mtime failed: %s", packageName, chtimesErr)
}
return
}
// UninstallPackage 卸载集市包
func UninstallPackage(installPath string) (err error) {
packageInstallLock.Lock()
defer packageInstallLock.Unlock()
if err = os.RemoveAll(installPath); err != nil {
logging.LogErrorf("remove [%s] failed: %s", installPath, err)
return fmt.Errorf("remove community package [%s] failed", filepath.Base(installPath))
}
return
}
View on GitHub (pinned to 9f775e8a12)