siyuan-note/siyuan · warning · ErrLocalBazaarPackageExists
marketplace package already exists
Error message
marketplace package already exists
What it means
ErrLocalBazaarPackageExists is a sentinel returned by InstallLocalBazaarPackage when the target package already exists locally and has pending updates (result.Updated) but the caller did not request overwrite. The API layer maps it to reason "package-exists" in the batch-install result, so callers can detect the 'already installed, update available, confirm needed' case via errors.Is.
Solutions
- Pass overwrite=true if the existing package should be replaced
- Use errors.Is(err, model.ErrLocalBazaarPackageExists) to detect this case and prompt the user for overwrite confirmation before retrying
- Uninstall the existing package first if a clean install is desired
Example fix
// before
_, err := model.InstallLocalBazaarPackage(src, "plugins", false, frontend)
// after
_, err := model.InstallLocalBazaarPackage(src, "plugins", false, frontend)
if errors.Is(err, model.ErrLocalBazaarPackageExists) {
_, err = model.InstallLocalBazaarPackage(src, "plugins", true, frontend) // user confirmed
} Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check: does the package already exist and differ? const exists = await api.isPackageInstalled(pkgType, pkgName);
Type guard
function isPackageExists(err) { return errors.Is(err, model.ErrLocalBazaarPackageExists); } Try / catch
_, err := model.InstallLocalBazaarPackage(src, pkgType, false, frontend)
if errors.Is(err, model.ErrLocalBazaarPackageExists) {
if userConfirmsOverwrite() {
_, err = model.InstallLocalBazaarPackage(src, pkgType, true, frontend)
}
} Prevention
- Check whether the package is already installed before a local install
- Wire overwrite confirmation into the UI flow using the "package-exists" reason
- Use errors.Is, not string comparison, against the sentinel
When it happens
Trigger: Calling InstallLocalBazaarPackage for a package whose installed copy differs from the source (Updated=true) while overwrite is false; batch local installs via kernel/api/bazaar.go where an item already exists.
Common situations: Re-running a local install of a plugin/theme that is already installed; a UI asking the user whether to overwrite and the caller passing overwrite=false; scripted installs repeated without overwrite.
Understand the failure class
Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.
Related errors
- marketplace package is incompatible
- bazaarRatingRateLimited
- Conf.Language(46)
- bazaar is offline
- bazaar package information has not synced yet
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/b82dc07fe782aab5.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/bazaar.go:111
meta installMeta
}
// ThemeInstallOptions 描述新安装主题后需要应用的外观模式
type ThemeInstallOptions struct {
Mode int
ModeOS bool
}
// LocalBazaarPackageInstallResult 描述本地集市包的识别和安装结果。
type LocalBazaarPackageInstallResult struct {
PackageType string `json:"packageType"`
PackageName string `json:"packageName"`
MinAppVersion string `json:"minAppVersion,omitempty"`
Updated bool `json:"updated"`
}
var (
ErrLocalBazaarPackageExists = errors.New("marketplace package already exists")
ErrLocalBazaarPackageIncompatible = errors.New("marketplace package is incompatible")
localBazaarInstallLock sync.Mutex
)
// updatePackages 更新一组集市包;同类型批量更新时,安装后处理只执行一次
func updatePackages(packages []*UpdatedPackage, pkgType string, successCount, failedCount *int, planned int) {
items := make([]batchInstallItem, 0, len(packages))
for _, updated := range packages {
pkg := updated.Available
meta, err := installBazaarPackage(pkgType, pkg.RepoURL, pkg.RepoHash, pkg.RepoRef, pkg.Name)
if err != nil {
logging.LogErrorf("update %s [%s] failed: %s", pkgType, pkg.Name, err)
util.PushErrMsg(fmt.Sprintf(Conf.language(238), pkg.Name), 5000)
*failedCount++
continue
}
items = append(items, batchInstallItem{name: pkg.Name, meta: meta})
*successCount++View on GitHub (pinned to 9f775e8a12)