{"record":{"id":"1b5452690977f3bb","repo":"siyuan-note/siyuan","slug":"uninstall-failed-s","errorCode":null,"errorMessage":"Uninstall failed: %s","messagePattern":"Uninstall failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/bazaar.go","lineNumber":698,"sourceCode":"\t\treturn \"\", err\n\t}\n\tfor _, info := range installedInfos {\n\t\tif info.Pkg.Name == packageName {\n\t\t\treturn filepath.Join(basePath, info.DirName), nil\n\t\t}\n\t}\n\treturn \"\", errors.New(\"installed package not found\")\n}\n\nfunc UninstallPackage(pkgType, packageName string) error {\n\tinstallPath, err := getPackageUninstallPath(pkgType, packageName)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = bazaar.UninstallPackage(installPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(Conf.Language(47), err.Error())\n\t}\n\n\t// 删除集市包的持久化信息\n\tbazaar.RemovePackageInfo(pkgType, packageName)\n\tbazaar.RemoveInstalledPackageSizeCache(pkgType, packageName)\n\n\tswitch pkgType {\n\tcase \"plugins\":\n\t\tpetals := getPetals()\n\t\tvar tmp []*Petal\n\t\tfor i, petal := range petals {\n\t\t\tif petal.Name != packageName {\n\t\t\t\ttmp = append(tmp, petals[i])\n\t\t\t}\n\t\t}\n\t\tpetals = tmp\n\t\tsavePetals(petals)\n","sourceCodeStart":680,"sourceCodeEnd":716,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/afa823b6b4e4f183511e0bc0a3be93caa94c7c97/kernel/model/bazaar.go#L680-L716","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Disable the plugin (remove it from enabled petals) or close the workspace/app so no process holds the files, then uninstall again","Check and fix permissions on the package directory (chmod/chown on Linux, clear read-only on Windows)","Exclude the workspace from antivirus/sync real-time scanning or pause it, then retry","As a last resort remove the folder manually and call bazaar.RemovePackageInfo / RemoveInstalledPackageSizeCache equivalents by reinstalling+uninstalling to clean metadata"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-flight: ensure nothing obvious holds the directory (best-effort)\nif _, err := os.Stat(installPath); err != nil {\n    return err // will surface as 'installed package not found' upstream instead\n}","typeGuard":null,"tryCatchPattern":"err := model.UninstallPackage(pkgType, name)\nif err != nil {\n    if strings.Contains(err.Error(), \"Uninstall failed\") || strings.Contains(err.Error(), Conf.Language(47)[:10]) {\n        // instruct: disable plugin / close app / check permissions, then retry once\n    }\n}","preventionTips":["On Windows, disable the plugin and let the app release module handles before uninstalling","Pause sync/antivirus tools that lock workspace directories during uninstall","After a failed uninstall, verify whether the folder is gone before retrying (second try returns 'installed package not found')"],"tags":["marketplace","bazaar","uninstall","file-locking","permissions","windows"],"backgroundTag":"file-removal-failed","analyzedSha":"afa823b6b4e4f183511e0bc0a3be93caa94c7c97","analyzedAt":"2026-08-18T17:04:10.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}