siyuan-note/siyuan · info

Langs[Lang][266]

Error message

Langs[Lang][266]

What it means

OcrAsset performs Tesseract OCR on an image asset, but only when the TesseractEnabled flag is set (requires the tesseract binary to be found/configured). When OCR is disabled, it returns a localized message from Langs[Lang][266] — the i18n string telling the user OCR is not enabled — instead of running OCR. It is an expected precondition failure, surfaced to the UI as a localized notice.

Solutions

  1. Install tesseract-ocr (plus required language packs, e.g. tesseract-ocr-chi-sim) and make sure it is on PATH, then restart SiYuan
  2. Enable the OCR setting in SiYuan (Settings - Assets - OCR / enable Tesseract) after installation
  3. If OCR is intentionally off, stop issuing OCR requests; the error is expected in this state
  4. In containerized deployments, switch to an image variant that includes tesseract or add it to the Dockerfile

Example fix

// before
texts, _ := util.OcrAsset(asset) // error: OCR not enabled
// after
if util.TesseractEnabled {
    texts, err := util.OcrAsset(asset)
    if err != nil { return err }
} else {
    return errors.New("tesseract OCR is not installed or disabled; install tesseract-ocr and enable it in settings")
}
Defensive patterns

Strategy: fallback

Validate before calling

// Go: skip OCR work when Tesseract is not enabled
if !util.TesseractEnabled {
    return nil // or handle asset without OCR text
}

Try / catch

texts, err := util.OcrAsset(asset)
if err != nil {
    if strings.Contains(err.Error(), util.Langs[util.Lang][266]) {
        logging.LogWarnf("OCR disabled, skipping asset %s", asset)
        return nil
    }
    return err
}

Prevention

When it happens

Trigger: Calling OcrAsset (directly or via the OCR-related API/anonymous caller in asset indexing) when TesseractEnabled is false — i.e. the tesseract executable was not detected at startup or OCR was turned off in settings, yet an OCR request/asset-text rebuild was issued.

Common situations: Tesseract not installed on Linux server/desktop builds (SiYuan does not bundle it everywhere); PATH lacking the tesseract binary; user invokes 'extract image text' or rebuilds asset OCR index after disabling OCR; Docker image without tesseract installed.

Related errors


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

Appendix: source

Thrown at kernel/util/ocr.go:161

	assetsTextsLock.Lock()
	oldText, ok := assetsTexts[asset]
	assetsTexts[asset] = text
	assetsTextsLock.Unlock()
	if !ok || oldText != text {
		assetsTextsChanged.Store(true)
	}
}

func ExistsAssetText(asset string) (ret bool) {
	assetsTextsLock.Lock()
	_, ret = assetsTexts[asset]
	assetsTextsLock.Unlock()
	return
}

func OcrAsset(asset string) (ret []map[string]string, err error) {
	if !TesseractEnabled {
		err = errors.New(Langs[Lang][266])
		return
	}

	assetsPath := GetDataAssetsAbsPath()
	assetAbsPath := strings.TrimPrefix(asset, "assets")
	assetAbsPath = filepath.Join(assetsPath, assetAbsPath)
	ret = Tesseract(assetAbsPath)
	assetsTextsLock.Lock()
	ocrText := GetOcrJsonText(ret)
	assetsTexts[asset] = ocrText
	assetsTextsLock.Unlock()
	if "" != ocrText {
		assetsTextsChanged.Store(true)
	}
	return
}

func GetAssetText(asset string) (ret string) {

View on GitHub (pinned to 9f775e8a12)