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

  1. Close applications holding files in the package directory (other SiYuan instances, editors, AV scans) and retry uninstall
  2. Check and fix permissions/ownership on the package directory
  3. Restart the SiYuan kernel to release in-process handles, then uninstall
  4. 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

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


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)