{"record":{"id":"db0b74b984c9fde6","repo":"siyuan-note/siyuan","slug":"errpandocnotfound","errorCode":"ErrPandocNotFound","errorMessage":"not found executable pandoc","messagePattern":"not found executable pandoc","errorType":"exception","errorClass":null,"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/8641553a1f07374001902d3ce773285db1292b2d/kernel/util/pandoc.go#L15-L51","documentation":"ErrPandocNotFound is the sentinel error returned when a pandoc-backed conversion is requested but no usable pandoc executable is available. GetPandocRuntime() resolves pandoc's path (pandocBinPath); if it is empty (pandoc not installed or not found on PATH / in the install dir) or the kernel is not running in the standard container mode expected for the bundled pandoc, ConvertPandoc, Pandoc, and runClipboardMathPandoc return this error instead of shelling out.","triggerScenarios":"Calling kernel/util Pandoc(), ConvertPandoc(), runClipboardMathPandoc(), or the API route in kernel/api/lute_clipboard_math.go (clipboard math conversion) when GetPandocRuntime().BinPath is \"\" or Container != ContainerStd.","commonSituations":"pandoc not installed on a self-hosted desktop/server install; pandoc not on PATH for the user running the SiYuan kernel; running inside Docker with a slim image lacking pandoc; PATH differences between the service manager (systemd) and the interactive shell.","solutions":["Install pandoc (https://pandoc.org/installing.html or your package manager) and ensure it is on the PATH of the process running the kernel.","Restart SiYuan after installing so GetPandocRuntime() re-detects the binary.","If running in Docker, use the full image that bundles pandoc or add pandoc to your image build.","Verify with `pandoc --version` under the same user/environment as the kernel (e.g. `sudo -u siyuan pandoc --version` for services)."],"exampleFix":"// before\n// Dockerfile: FROM siyuan/siyuan:base-slim // no pandoc\n// after\n// Dockerfile:\n// FROM siyuan/siyuan:base-slim\n// RUN apt-get update && apt-get install -y pandoc && rm -rf /var/lib/apt/lists/*","handlingStrategy":"fallback","validationCode":"binPath := util.GetPandocRuntime().BinPath\nif binPath == \"\" || util.ContainerStd != util.Container {\n    return util.ErrPandocNotFound // degrade gracefully, e.g. skip math conversion\n}","typeGuard":"func pandocAvailable() bool {\n    return util.GetPandocRuntime().BinPath != \"\" && util.ContainerStd == util.Container\n}","tryCatchPattern":"out, err := util.Pandoc(from, to, o, content)\nif errors.Is(err, util.ErrPandocNotFound) {\n    logging.LogWarnf(\"pandoc unavailable, falling back to raw markdown export\")\n    return exportRawMarkdown(content, o)\n}","preventionTips":["Install pandoc before enabling pandoc-dependent export features","Ensure pandoc is on the PATH of the user running the kernel (systemd units often have a minimal PATH)","Use the full Docker image or add pandoc to your image","Check for ErrPandocNotFound at startup and surface a clear setup hint to users"],"tags":["pandoc","external-binary","missing-dependency","export"],"backgroundTag":"missing-dependency","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}