{"record":{"id":"5f27b0dc427b98b6","repo":"siyuan-note/siyuan","slug":"localized-uninstall-failure-message-conf-language","errorCode":null,"errorMessage":"localized uninstall failure message (Conf.Language(47)) with error detail","messagePattern":"localized uninstall failure message \\(Conf\\.Language\\(47\\)\\) with error detail","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/bazaar.go","lineNumber":707,"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":689,"sourceCodeEnd":725,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/bazaar.go#L689-L725","documentation":"UninstallPackage resolves the install path and then calls bazaar.UninstallPackage to delete the package directory. If the deletion fails, the kernel wraps the error with the localized message Conf.Language(47) and the error detail. The package remains on disk because the actual removal operation failed.","triggerScenarios":"Calling UninstallPackage where bazaar.UninstallPackage fails — typically because files in the install directory are locked (editor/plugin still loaded), the process lacks write/delete permission on the package directory, or the directory was concurrently removed.","commonSituations":"Uninstalling a theme/plugin that is currently in use on Windows (file in use); kernel process running without permission over another user's package directory; antivirus holding files open; network-mapped workspace drives with delayed deletes.","solutions":["Read the wrapped detail in the message to identify the OS-level cause.","Ensure the package is not in use (disable the plugin/switch themes) and retry the uninstall.","Check write/delete permissions on the workspace's package directory and remove locks (antivirus, other processes).","As a last resort, manually delete the package directory, then remove its persisted info via bazaar.RemovePackageInfo."],"exampleFix":"// before: uninstalling while plugin is active\nmodel.UninstallPackage(\"plugins\", \"my-plugin\")\n// after: disable the plugin first, then uninstall\nmodel.UninstallPackage(\"plugins\", \"my-plugin\") // ensure disablePlugin ran first\n// e.g. api: POST /api/bazaar/uninstallBazaarPlugin after disabling via setting","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := model.UninstallPackage(pkgType, name); err != nil {\n    log.Errorf(\"uninstall failed (package may be in use): %v\", err)\n    return fmt.Errorf(\"uninstall %s failed: %w\", name, err)\n}","preventionTips":["Disable/deactivate the package before uninstalling","Check file locks and permissions on the package directory","Retry once after a short delay if deletion fails on Windows"],"tags":["go","marketplace","uninstall","filesystem"],"backgroundTag":"file-write-failed","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}