{"record":{"id":"e6150bafd41305da","repo":"siyuan-note/siyuan","slug":"install-local-marketplace-package-failed-w-roll","errorCode":null,"errorMessage":"install local marketplace package failed: %w; rollback failed: %s","messagePattern":"install local marketplace package failed: %w; rollback failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/bazaar/install.go","lineNumber":221,"sourceCode":"\tdefer func() {\n\t\tif !preserveOperationPath {\n\t\t\t_ = os.RemoveAll(operationPath)\n\t\t}\n\t}()\n\tif err = filelock.Copy(sourcePath, stagingPath); err != nil {\n\t\treturn\n\t}\n\n\tif update {\n\t\tif err = os.Rename(installPath, backupPath); err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\tif err = os.Rename(stagingPath, installPath); err != nil {\n\t\tif update {\n\t\t\tif rollbackErr := os.Rename(backupPath, installPath); rollbackErr != nil {\n\t\t\t\tpreserveOperationPath = true\n\t\t\t\treturn fmt.Errorf(\"install local marketplace package failed: %w; rollback failed: %s\", err, rollbackErr)\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tif update {\n\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}","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/afa823b6b4e4f183511e0bc0a3be93caa94c7c97/kernel/bazaar/install.go#L203-L239","documentation":"InstallLocalPackage installs via rename dance: copy source to a staging dir, on update rename installPath to a backup, then rename staging into place. This error means the final rename failed AND the rollback rename (backup -> installPath) failed too — installPath is left missing and the previous version survives only in the deliberately preserved .siyuan-package-install-XXXXXX/backup directory (preserveOperationPath keeps the deferred cleanup from deleting it).","triggerScenarios":"Updating a locally-installed package (update=true) when the final os.Rename fails and the rollback os.Rename also fails — typically because installPath or files inside are held open, ACLs deny rename, or the volume has errors.","commonSituations":"Windows: Explorer preview, antivirus, or the running frontend holding the plugin directory open; permission/ownership changes on the workspace; disk full; stale .siyuan-package-install-* directories from a previous crash.","solutions":["Close programs holding the package directory open (Explorer windows, editors, the loaded plugin) and retry the update","Recover manually: find the preserved .siyuan-package-install-*/backup next to the install dir and move its contents back into installPath","Check permissions and free space on the workspace volume, then re-run the update","After recovery, delete leftover .siyuan-package-install-* directories"],"exampleFix":"# before - blindly retry the update (installPath still missing)\n# after - recover the preserved backup first\nls -d /path/to/plugins/.siyuan-package-install-*      # locate the preserved operation dir\nmv /path/to/plugins/.siyuan-package-install-*/backup/* /path/to/plugins/<name>/\nrm -rf /path/to/plugins/.siyuan-package-install-*\n# then re-run the package update","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := bazaar.InstallLocalPackage(srcPath, installPath, pkgType, name, true)\nif err != nil && strings.Contains(err.Error(), \"rollback failed\") {\n    // installPath is now missing; recover from the preserved .siyuan-package-install-*/backup dir\n    // before any other operation touches this package\n}","preventionTips":["Close programs holding the package directory (Explorer, editors, the loaded plugin) before updating","Watch for .siyuan-package-install-* leftovers and clean them after recovery","Ensure the workspace volume is writable and has free space before package updates"],"tags":["bazaar","install","filesystem","rollback","atomic-rename","go"],"backgroundTag":"atomic-rename-failure","analyzedSha":"afa823b6b4e4f183511e0bc0a3be93caa94c7c97","analyzedAt":"2026-08-18T17:04:10.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}