{"record":{"id":"db0b74b984c9fde6","repo":"siyuan-note/siyuan","slug":"errpandocnotfound","errorCode":"ErrPandocNotFound","errorMessage":"not found executable pandoc","messagePattern":"not found executable pandoc","errorType":"exception","errorClass":"ErrPandocNotFound","httpStatus":null,"severity":"error","filePath":"kernel/util/pandoc.go","lineNumber":33,"sourceCode":"// along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\npackage util\n\nimport (\n\t\"bytes\"\n\t\"errors\"\n\t\"os\"\n\t\"os/exec\"\n\t\"path/filepath\"\n\t\"runtime\"\n\t\"strings\"\n\t\"sync\"\n\n\t\"github.com/88250/gulu\"\n\t\"github.com/siyuan-note/logging\"\n)\n\nvar ErrPandocNotFound = errors.New(\"not found executable pandoc\")\n\nfunc ConvertPandoc(dir string, args ...string) (path string, err error) {\n\tpandocBinPath := GetPandocRuntime().BinPath\n\tif \"\" == pandocBinPath || ContainerStd != Container {\n\t\terr = ErrPandocNotFound\n\t\treturn\n\t}\n\n\tpandoc := exec.Command(pandocBinPath, args...)\n\tgulu.CmdAttr(pandoc)\n\tpath = filepath.Join(\"temp\", \"convert\", \"pandoc\", dir)\n\tabsPath := filepath.Join(WorkspaceDir, path)\n\tif err = os.MkdirAll(absPath, 0755); err != nil {\n\t\tlogging.LogErrorf(\"mkdir [%s] failed: [%s]\", absPath, err)\n\t\treturn\n\t}\n\tpandoc.Dir = absPath\n\toutput, err := pandoc.CombinedOutput()","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/util/pandoc.go#L15-L51","documentation":"ErrPandocNotFound (kernel/util/pandoc.go:33) is returned by ConvertPandoc and Pandoc when GetPandocRuntime().BinPath is empty OR the kernel is not in ContainerStd mode (i.e. it is running in Docker or on mobile). InitPandoc only locates a binary on desktop builds; in other containers the runtime is intentionally left empty, so any pandoc-dependent conversion fails fast with this sentinel error.","triggerScenarios":"Calling ConvertPandoc/Pandoc when: (a) the desktop kernel booted without a bundled pandoc binary present and the user has not set a custom pandoc path, or (b) Container != ContainerStd (Docker image, Android, iOS, HarmonyOS gomobile builds).","commonSituations":"Fresh desktop install where the pandoc/ subdirectory was not shipped; user uninstalled/relocated pandoc; running the official Docker image (no pandoc bundled); mobile/harmony builds; the custom pandoc path set in settings points to a non-existent file (InitPandoc validates the version and falls back to empty).","solutions":["On desktop, set 设置 - 导出 - Pandoc 可执行文件路径 to a valid pandoc binary (validate with IsValidPandocBin).","Install pandoc system-wide (e.g. apt install pandoc, brew install pandoc) and point SiYuan at it.","On Docker/mobile, do not invoke pandoc-dependent import/export paths — fall back to plain Markdown.","Verify the bundled pandoc binary exists at WorkingDir/pandoc/bin/pandoc on desktop."],"exampleFix":"// before\npath, err := util.ConvertPandoc(dir, args...)\nif err != nil { return err }\n\n// after (graceful degradation when pandoc is unavailable)\npath, err := util.ConvertPandoc(dir, args...)\nif errors.Is(err, util.ErrPandocNotFound) {\n    logging.LogWarnf(\"pandoc unavailable, falling back to plain markdown: %s\", err)\n    return writePlainMarkdown(dir)\n}\nif err != nil { return err }","handlingStrategy":"validation","validationCode":"// Pre-check pandoc availability and container mode before calling Convert/Pandoc\nif util.GetPandocRuntime().BinPath == \"\" || util.ContainerStd != util.Container {\n    return util.ErrPandocNotFound // or fall back to plain markdown\n}","typeGuard":null,"tryCatchPattern":"path, err := util.ConvertPandoc(dir, args...)\nif err != nil {\n    if errors.Is(err, util.ErrPandocNotFound) {\n        logging.LogWarnf(\"pandoc unavailable; falling back to plain export\")\n        return exportPlainMarkdown(dir)\n    }\n    return err\n}","preventionTips":["On desktop, configure 设置 - 导出 - Pandoc 可执行文件路径 and validate with IsValidPandocBin.","Do not call pandoc-dependent paths in Docker/mobile/harmony builds (Container != ContainerStd).","When upgrading SiYuan, confirm the bundled WorkingDir/pandoc/bin/pandoc binary is present."],"tags":["pandoc","export","container","go","sentinel"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}