siyuan-note/siyuan · error

install local marketplace package failed

Error message

install local marketplace package failed: %w; rollback failed: %s

What it means

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).

Solutions

  1. Close programs holding the package directory open (Explorer windows, editors, the loaded plugin) and retry the update
  2. Recover manually: find the preserved .siyuan-package-install-*/backup next to the install dir and move its contents back into installPath
  3. Check permissions and free space on the workspace volume, then re-run the update
  4. After recovery, delete leftover .siyuan-package-install-* directories

Example fix

# before - blindly retry the update (installPath still missing)
# after - recover the preserved backup first
ls -d /path/to/plugins/.siyuan-package-install-*      # locate the preserved operation dir
mv /path/to/plugins/.siyuan-package-install-*/backup/* /path/to/plugins/<name>/
rm -rf /path/to/plugins/.siyuan-package-install-*
# then re-run the package update
Defensive patterns

Strategy: fallback

Try / catch

err := bazaar.InstallLocalPackage(srcPath, installPath, pkgType, name, true)
if err != nil && strings.Contains(err.Error(), "rollback failed") {
    // installPath is now missing; recover from the preserved .siyuan-package-install-*/backup dir
    // before any other operation touches this package
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of siyuan-note/siyuan@afa823b6b4 (2026-08-18). Data as JSON: /api/errors/e6150bafd41305da. Report an issue: GitHub.

Appendix: source

Thrown at kernel/bazaar/install.go:221

	defer func() {
		if !preserveOperationPath {
			_ = os.RemoveAll(operationPath)
		}
	}()
	if err = filelock.Copy(sourcePath, stagingPath); err != nil {
		return
	}

	if update {
		if err = os.Rename(installPath, backupPath); err != nil {
			return
		}
	}
	if err = os.Rename(stagingPath, installPath); err != nil {
		if update {
			if rollbackErr := os.Rename(backupPath, installPath); rollbackErr != nil {
				preserveOperationPath = true
				return fmt.Errorf("install local marketplace package failed: %w; rollback failed: %s", err, rollbackErr)
			}
		}
		return
	}
	if update {
		if removeErr := os.RemoveAll(operationPath); removeErr != nil {
			logging.LogWarnf("remove local package backup [%s] failed: %s", backupPath, removeErr)
		}
	}

	RemoveInstalledPackageSizeCache(pkgType, packageName)
	now := time.Now()
	recordPackageOperationTime(pkgType, packageName, now, fallbackInstallTime, update)
	if chtimesErr := os.Chtimes(installPath, now, now); chtimesErr != nil {
		logging.LogWarnf("set package [%s] folder mtime failed: %s", packageName, chtimesErr)
	}
	return
}

View on GitHub (pinned to afa823b6b4)