{"record":{"id":"04e132ab27047b78","repo":"siyuan-note/siyuan","slug":"remove-community-package-s-failed","errorCode":null,"errorMessage":"remove community package [%s] failed","messagePattern":"remove community package \\[(.+?)\\] failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/bazaar/install.go","lineNumber":243,"sourceCode":"\t\tif removeErr := os.RemoveAll(operationPath); removeErr != nil {\n\t\t\tlogging.LogWarnf(\"remove local package backup [%s] failed: %s\", backupPath, removeErr)\n\t\t}\n\t}\n\n\tRemoveInstalledPackageSizeCache(pkgType, packageName)\n\tnow := time.Now()\n\trecordPackageOperationTime(pkgType, packageName, now, fallbackInstallTime, update)\n\tif chtimesErr := os.Chtimes(installPath, now, now); chtimesErr != nil {\n\t\tlogging.LogWarnf(\"set package [%s] folder mtime failed: %s\", packageName, chtimesErr)\n\t}\n\treturn\n}\n\n// UninstallPackage 卸载集市包\nfunc UninstallPackage(installPath string) (err error) {\n\tif err = os.RemoveAll(installPath); err != nil {\n\t\tlogging.LogErrorf(\"remove [%s] failed: %s\", installPath, err)\n\t\treturn fmt.Errorf(\"remove community package [%s] failed\", filepath.Base(installPath))\n\t}\n\treturn\n}\n","sourceCodeStart":225,"sourceCodeEnd":247,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/bazaar/install.go#L225-L247","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure the package is not actively loaded — disable or close the plugin/theme before uninstalling","Check filesystem permissions on the install path and its children","Retry the uninstall after closing applications that may hold file handles","On Windows, use a tool like Resource Monitor to identify which process locks the files","Manually remove the directory if the automatic cleanup left residual files"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"func checkRemovable(installPath string) error {\n    info, err := os.Stat(installPath)\n    if err != nil {\n        return err\n    }\n    if info.IsDir() {\n        // Try to create and remove a test file inside\n        test := filepath.Join(installPath, \".remove-test\")\n        if err := os.WriteFile(test, nil, 0644); err != nil {\n            return fmt.Errorf(\"directory not removable (locked or read-only): %w\", err)\n        }\n        os.Remove(test)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"err := bazaar.UninstallPackage(installPath)\nif err != nil {\n    if strings.Contains(err.Error(), \"remove community package\") {\n        // Retry once after a short delay — file locks may be transient\n        time.Sleep(2 * time.Second)\n        err = bazaar.UninstallPackage(installPath)\n    }\n    if err != nil {\n        // As a last resort, attempt manual recursive removal\n        os.RemoveAll(installPath)\n    }\n}","preventionTips":["Disable or unload the package (plugin/theme) before uninstalling to release file handles","On Windows, close other applications that may lock package files (antivirus, editors)","Retry uninstall after a brief delay — transient locks from file indexers are common","Ensure the SiYuan process has write/delete permissions on the package directory"],"tags":["bazaar","marketplace","uninstall","filesystem","go"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}