siyuan-note/siyuan · critical
install marketplace package failed
Error message
install marketplace package failed: %w; rollback failed: %s
What it means
replacePackageDirectory swaps the staged directory into installPath with os.Rename. If that rename fails after an old target was moved to a backup, it attempts to roll back by restoring the backup; when the rollback ALSO fails, it reports both the original install failure and the rollback failure, and preserves the operation directory for manual recovery.
Solutions
- Inspect the preserved operation path mentioned by the kernel logs and manually restore/repair the package directory
- Close processes holding handles in the package dir (AV scanners, editors, sync clients) and retry the install/update
- Ensure staging dir (util.TempDir) and the data/packages dir are on the same filesystem/volume
- Check disk space and write permissions on the packages directory
Example fix
// before: temp on /tmp (tmpfs), packages on /home -> os.Rename EXDEV // after: set the workspace temp directory on the same volume as data/, then retry the update
Defensive patterns
Strategy: try-catch
Validate before calling
if st, err := os.Stat(installPath); err == nil {
if ok, _ := hasOpenHandles(installPath); ok { return fmt.Errorf("package dir busy; close apps using it") }
}
// ensure staging and target share a device
if !sameDevice(util.TempDir, filepath.Dir(installPath)) { return errors.New("staging volume differs from install volume") } Try / catch
if err := installPackage(...); err != nil && strings.Contains(err.Error(), "rollback failed") {
// state on disk may be inconsistent: locate the preserved operation path,
// manually restore backup or remove staging, then retry with a clean dir
} Prevention
- Keep util.TempDir and data/ on the same filesystem so rename is atomic
- Exclude the workspace from antivirus/sync tools that lock directories mid-rename
- Ensure free disk space and writable permissions before updates
- After a failed update, verify package dir integrity before launching plugins
When it happens
Trigger: The rename or restore fails due to filesystem-level problems: target directory locked by another process, cross-device rename, permission issues, or the backup path no longer renameable.
Common situations: Antivirus/indexer (or another SiYuan instance) holding handles inside the package directory on Windows; installPath on a different mount than the staging dir (os.Rename across devices fails); disk full or permission loss mid-update leaving the package dir in a half-replaced state.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- install local marketplace package failed
- rollback [ ] to [ ] failed
- errors.New(msg) with Conf.Language(5) template: move…
- localized message from Conf.Language(5) formatted with…
- marketplace package install path already exists
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/0323889eaed6d277.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/bazaar/install.go:236
return statErr
}
if targetExists && !update && containsFile {
return errors.New("marketplace package install path already exists")
}
if update && !targetExists {
return os.ErrNotExist
}
if targetExists {
if err = os.Rename(installPath, backupPath); err != nil {
return
}
}
if err = os.Rename(stagingPath, installPath); err != nil {
if targetExists {
if rollbackErr := os.Rename(backupPath, installPath); rollbackErr != nil {
preserveOperationPath = true
return fmt.Errorf("install marketplace package failed: %w; rollback failed: %s", err, rollbackErr)
}
}
return
}
if targetExists {
if removeErr := os.RemoveAll(operationPath); removeErr != nil {
logging.LogWarnf("remove package backup [%s] failed: %s", backupPath, removeErr)
}
}
return
}
// InstallLocalPackage 从已解压并验证的目录安装本地集市包。
func InstallLocalPackage(sourcePath, installPath, pkgType, packageName string, update bool) (err error) {
var fallbackInstallTime time.Time
if info, statErr := os.Stat(installPath); statErr == nil {
fallbackInstallTime = info.ModTime()
}View on GitHub (pinned to 9f775e8a12)