siyuan-note/siyuan · error

remove community package [%s] failed

Error message

remove community package [%s] failed

What it means

Returned by UninstallPackage (kernel/bazaar/install.go:241-243) when os.RemoveAll(installPath) fails during package uninstall. The underlying OS error is logged via LogErrorf, and the returned error message includes the package directory's base name (filepath.Base(installPath)) for identification.

Source

Thrown at kernel/bazaar/install.go:243

		if removeErr := os.RemoveAll(operationPath); removeErr != nil {
			logging.LogWarnf("remove local package backup [%s] failed: %s", backupPath, removeErr)
		}
	}

	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) {
	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 251596fc0d)

Solutions

  1. Ensure the package is not actively loaded — disable or close the plugin/theme before uninstalling
  2. Check filesystem permissions on the install path and its children
  3. Retry the uninstall after closing applications that may hold file handles
  4. On Windows, use a tool like Resource Monitor to identify which process locks the files
  5. Manually remove the directory if the automatic cleanup left residual files
Defensive patterns

Strategy: try-catch

Validate before calling

func checkRemovable(installPath string) error {
    info, err := os.Stat(installPath)
    if err != nil {
        return err
    }
    if info.IsDir() {
        // Try to create and remove a test file inside
        test := filepath.Join(installPath, ".remove-test")
        if err := os.WriteFile(test, nil, 0644); err != nil {
            return fmt.Errorf("directory not removable (locked or read-only): %w", err)
        }
        os.Remove(test)
    }
    return nil
}

Try / catch

err := bazaar.UninstallPackage(installPath)
if err != nil {
    if strings.Contains(err.Error(), "remove community package") {
        // Retry once after a short delay — file locks may be transient
        time.Sleep(2 * time.Second)
        err = bazaar.UninstallPackage(installPath)
    }
    if err != nil {
        // As a last resort, attempt manual recursive removal
        os.RemoveAll(installPath)
    }
}

Prevention

When it happens

Trigger: Calling UninstallPackage when the package directory cannot be fully removed — a file inside it is locked, permissions are insufficient, or the path doesn't exist in a way that causes an error.

Common situations: On Windows, a file in the plugin/theme directory is locked by the Electron process or another application; read-only filesystem; permission denied on a subdirectory; the package's files are in use (e.g. a plugin is actively running); race condition where the directory was already partially removed.

Related errors


AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12). Data as JSON: /api/errors/04e132ab27047b78. Report an issue: GitHub.