siyuan-note/siyuan · error

installed package not found

Error message

installed package not found

What it means

GetInstalledPackageSize scans all locally installed packages of the given pkgType and, when none has a package.json `name` matching packageName, returns this sentinel error. It means the package is not recognized as installed — its directory is missing, its package metadata failed to parse, or the name does not match. It is an internal lookup failure, not a size-calculation failure.

Solutions

  1. Verify the package exists under the workspace dir for its type (themes/, icons/, plugins/, widgets/, templates/) with a valid package.json whose name matches
  2. Check for typos in packageName and that pkgType is correct
  3. Reinstall the package from the marketplace, then query its size
  4. If the folder exists but is corrupt, delete it and reinstall

Example fix

// before: querying size for a package assumed installed
size, _, err := model.GetInstalledPackageSize("plugins", "my-plugin")
// after: guard with the installed list first
if !isPackageInstalled("plugins", "my-plugin") { return errors.New("package not installed") }
size, _, err := model.GetInstalledPackageSize("plugins", "my-plugin")
Defensive patterns

Strategy: try-catch

Validate before calling

func isPackageInstalled(pkgType, name string) bool {
  pkgs := model.GetInstalledPackages(pkgType, "", "")
  for _, p := range pkgs { if p.Name == name && p.InvalidReason == "" { return true } }
  return false
}

Type guard

if info == nil || info.Pkg == nil || info.Pkg.Name != wantName { return false }

Try / catch

size, _, err := model.GetInstalledPackageSize(pkgType, name)
if err != nil {
  if strings.Contains(err.Error(), "installed package not found") { /* treat as absent, size 0 */ }
  return err
}

Prevention

When it happens

Trigger: Calling the kernel API that queries an installed package's size (GET /api/bazaar/getInstalledPackageSize style flows) with a pkgType/packageName that is not currently installed; the package directory was deleted manually; package.json in the package dir is missing/corrupt so info.Pkg.Name never matches; or a typo in the package name.

Common situations: Stale frontend state after manually deleting a theme/icon/plugin folder from the workspace; querying a package by marketplace name while the installed copy declares a different name in its package.json; calling before the first install ever happened.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/1005e4353377e6a7. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/bazaar.go:425

		}
	}
	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 9f775e8a12)