siyuan-note/siyuan · error

Uninstall failed

Error message

Uninstall failed: %s

What it means

Wrapped error produced in model.UninstallPackage (kernel/model/bazaar.go:698): when bazaar.UninstallPackage's os.RemoveAll of the install path fails, the cause is wrapped with Conf.Language(47) ("Uninstall failed: <cause>"). Removal failures are almost exclusively environmental: files or directories in the package being held open by another process or lacking delete permission.

Solutions

  1. Disable the plugin (remove it from enabled petals) or close the workspace/app so no process holds the files, then uninstall again
  2. Check and fix permissions on the package directory (chmod/chown on Linux, clear read-only on Windows)
  3. Exclude the workspace from antivirus/sync real-time scanning or pause it, then retry
  4. As a last resort remove the folder manually and call bazaar.RemovePackageInfo / RemoveInstalledPackageSizeCache equivalents by reinstalling+uninstalling to clean metadata
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-flight: ensure nothing obvious holds the directory (best-effort)
if _, err := os.Stat(installPath); err != nil {
    return err // will surface as 'installed package not found' upstream instead
}

Try / catch

err := model.UninstallPackage(pkgType, name)
if err != nil {
    if strings.Contains(err.Error(), "Uninstall failed") || strings.Contains(err.Error(), Conf.Language(47)[:10]) {
        // instruct: disable plugin / close app / check permissions, then retry once
    }
}

Prevention

When it happens

Trigger: Uninstalling a plugin while its files are loaded/locked (Windows DLL/JS load, running plugin process), antivirus scanning the directory mid-removal, read-only attributes or ACLs on the package folder, or the workspace living on a mount that does not permit deletes.

Common situations: Windows file locking (most common): the plugin was enabled and its code was required from data/plugins/<name>; OneDrive/sync clients holding handles; Linux directory made read-only or owned by another user; uninstalling a theme currently applied also goes through the same removal call.

Related errors


AI-assisted analysis of siyuan-note/siyuan@afa823b6b4 (2026-08-18). Data as JSON: /api/errors/1b5452690977f3bb. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/bazaar.go:698

		return "", err
	}
	for _, info := range installedInfos {
		if info.Pkg.Name == packageName {
			return filepath.Join(basePath, info.DirName), nil
		}
	}
	return "", errors.New("installed package not found")
}

func UninstallPackage(pkgType, packageName string) error {
	installPath, err := getPackageUninstallPath(pkgType, packageName)
	if err != nil {
		return err
	}

	err = bazaar.UninstallPackage(installPath)
	if err != nil {
		return fmt.Errorf(Conf.Language(47), err.Error())
	}

	// 删除集市包的持久化信息
	bazaar.RemovePackageInfo(pkgType, packageName)
	bazaar.RemoveInstalledPackageSizeCache(pkgType, packageName)

	switch pkgType {
	case "plugins":
		petals := getPetals()
		var tmp []*Petal
		for i, petal := range petals {
			if petal.Name != packageName {
				tmp = append(tmp, petals[i])
			}
		}
		petals = tmp
		savePetals(petals)

View on GitHub (pinned to afa823b6b4)