{"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":275,"sourceCode":"\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\tpackageInstallLock.Lock()\n\tdefer packageInstallLock.Unlock()\n\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":257,"sourceCodeEnd":279,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/bazaar/install.go#L257-L279","documentation":"UninstallPackage deletes the package directory with os.RemoveAll under the install lock. If removal fails for any reason, it logs the cause and returns an error identifying the package by its base directory name.","triggerScenarios":"os.RemoveAll fails on the package install path — typically permission errors on Windows (file locked by another process) or read-only filesystems.","commonSituations":"Package files locked by antivirus, editors, or another running SiYuan/Electron instance on Windows; directory made read-only by sync tools; network-mounted data dir temporarily unavailable; root-owned files after manual edits.","solutions":["Close applications holding files in the package directory (other SiYuan instances, editors, AV scans) and retry uninstall","Check and fix permissions/ownership on the package directory","Restart the SiYuan kernel to release in-process handles, then uninstall","Manually remove the directory if the filesystem permits, then refresh the marketplace UI"],"exampleFix":"// before: uninstall fails while another Electron window holds the plugin open\n// after: close the extra SiYuan window (or restart the app), then Settings - Marketplace - Uninstall","handlingStrategy":"try-catch","validationCode":"if _, err := os.Stat(installPath); err != nil { return nil } // nothing to uninstall\n// best-effort writability probe\nf, err := os.CreateTemp(installPath, \".probe*\")\nif err != nil { return fmt.Errorf(\"package dir not writable: %w\", err) }\nf.Close(); os.Remove(f.Name())","typeGuard":null,"tryCatchPattern":"if err := UninstallPackage(installPath); err != nil {\n    base := filepath.Base(installPath)\n    // likely locked on Windows or permission-denied: ask user to close apps,\n    // then retry once before surfacing a manual-removal instruction\n    retry(func() error { return UninstallPackage(installPath) }, 1)\n}","preventionTips":["Close other SiYuan instances/editors before uninstalling packages","Exclude the data directory from AV real-time scanning and file-sync tools","Keep package directories owned by the user running the kernel","If removal keeps failing, delete the directory manually and refresh the marketplace"],"tags":["filesystem","bazaar","uninstall","permissions"],"backgroundTag":"file-write-failed","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}