siyuan-note/siyuan · error

installed package not found

Error message

installed package not found

What it means

Thrown by GetInstalledPackageSize when, after enumerating installed packages of the given type, none has info.Pkg.Name equal to the requested packageName. The package is simply not installed under that type, so its size cannot be reported.

Source

Thrown at kernel/model/bazaar.go:436

		}
	}
	return
}

// GetInstalledPackageSize 获取本地集市包的安装大小
func GetInstalledPackageSize(pkgType, packageName string) (size int64, hSize string, err error) {
	installedInfos, basePath, _, err := GetInstalledPackageInfos(pkgType)
	if err != nil {
		return
	}
	for _, info := range installedInfos {
		if info.Pkg.Name != packageName {
			continue
		}
		installPath := filepath.Join(basePath, info.DirName)
		return bazaar.GetInstalledPackageSize(pkgType, packageName, installPath)
	}
	err = errors.New("installed package not found")
	return
}

// GetBazaarPackageDetail 获取单个集市包的本地安装信息和在线信息。
//
// 在线集市不可用时仍返回本地信息,避免网络问题阻断已下载包详情。
func GetBazaarPackageDetail(pkgType, packageName, frontend string) (installed, available *bazaar.Package) {
	for _, pkg := range GetInstalledPackages(pkgType, frontend, "") {
		if pkg.InvalidReason != "" {
			continue
		}
		if pkg.Name == packageName {
			installed = pkg
			break
		}
	}

	availablePackages, err := bazaar.GetBazaarPackagesMap(pkgType, frontend)

View on GitHub (pinned to 251596fc0d)

Solutions

  1. Verify the package is installed (list installed packages first) before requesting its size.
  2. Ensure packageName matches the manifest's name field, not just the directory name.
  3. Handle not-found gracefully in the caller by checking the installed list membership.

Example fix

// before
size, _, err := model.GetInstalledPackageSize(pkgType, name) // may be uninstalled
// after
installed := model.GetInstalledPackages(pkgType, frontend, "")
found := false
for _, p := range installed { if p.Name == name { found = true; break } }
if !found { return /* not installed */ }
Defensive patterns

Strategy: validation

Validate before calling

// Confirm the package is installed before requesting its size.
installed := model.GetInstalledPackages(pkgType, frontend, "")
found := false
for _, p := range installed {
    if p.Name == packageName {
        found = true
        break
    }
}
if !found {
    return // nothing to size
}
size, hSize, err := model.GetInstalledPackageSize(pkgType, packageName)

Try / catch

size, hSize, err := model.GetInstalledPackageSize(pkgType, packageName)
if err != nil {
    if err.Error() == "installed package not found" {
        // package not installed or name mismatch; refresh installed list
    }
    return
}

Prevention

When it happens

Trigger: Requesting the on-disk size of a plugin/theme/icon/template/widget that is not currently installed, or whose installed directory's manifest name does not match packageName (e.g. the directory was renamed).

Common situations: UI asking for a package size after it was uninstalled, or for a name that differs from the installed manifest name (directory vs. manifest mismatch). Also if the manifest failed to parse, the entry may carry the dir name rather than the declared name.

Related errors


AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12). Data as JSON: /api/errors/1005e4353377e6a7. Report an issue: GitHub.