{"record":{"id":"369cd0f6dee1f1fe","repo":"siyuan-note/siyuan","slug":"not-found-executable-pandoc","errorCode":null,"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/afa823b6b4e4f183511e0bc0a3be93caa94c7c97/kernel/util/pandoc.go#L15-L51","documentation":"ConvertPandoc and Pandoc refuse to run when GetPandocRuntime().BinPath is empty or the process runs in a non-standard container (ContainerStd != Container, e.g. Docker, where InitPandoc disables the runtime by design). BinPath is resolved once at startup from the bundled <WorkingDir>/pandoc/bin binary or from a custom path validated by IsValidPandocBin; empty means no usable pandoc executable was found.","triggerScenarios":"Triggering any pandoc-backed conversion (Word/Docx import, export to docx, pandoc-format conversion) on an installation where the bundled pandoc binary is missing, the configured custom pandoc path fails IsValidPandocBin (not a real Mach-O/ELF/PE binary, or its --version output does not start with 'pandoc'), or inside a Docker container where pandoc is intentionally disabled.","commonSituations":"Fresh or copied installations missing the pandoc folder; a custom path pointing to a script, symlink to nowhere, or wrong binary; permission problems executing pandoc; Docker deployments.","solutions":["Provide a working pandoc: install the bundled runtime under <WorkingDir>/pandoc/bin, or set a custom pandoc binary path in settings that passes IsValidPandocBin (a real binary whose --version starts with 'pandoc').","Restart or re-run InitPandoc after changing the path — the runtime is resolved at init time, not per call.","Verify with pandoc --version as the same user account that runs SiYuan to rule out permission issues.","In Docker, pandoc conversion is intentionally unavailable (ContainerStd != Container) — use a non-containerized setup or avoid pandoc-dependent flows."],"exampleFix":"// before: no pandoc installed, custom path empty\nutil.InitPandoc(\"\")\npath, err := util.ConvertPandoc(dir, args...) // -> ErrPandocNotFound\n\n// after: configure a valid binary (or ship <workdir>/pandoc/bin/pandoc)\nutil.InitPandoc(\"/usr/local/bin/pandoc\")\npath, err := util.ConvertPandoc(dir, args...)","handlingStrategy":"validation","validationCode":"if util.GetPandocRuntime().BinPath == \"\" {\n\treturn util.ErrPandocNotFound // or prompt the user to install/configure pandoc\n}\npath, err := util.ConvertPandoc(dir, args...)","typeGuard":null,"tryCatchPattern":"Compare with errors.Is(err, util.ErrPandocNotFound) and degrade gracefully — skip the conversion and tell the user to install pandoc, rather than retrying; it is a deterministic environment problem.","preventionTips":["Ship or install the pandoc runtime before enabling pandoc-based import/export","Validate custom pandoc paths with IsValidPandocBin at configuration time","Re-run InitPandoc after path changes","Remember pandoc is disabled inside containers"],"tags":["pandoc","missing-dependency","environment","import-export"],"backgroundTag":"missing-executable","analyzedSha":"afa823b6b4e4f183511e0bc0a3be93caa94c7c97","analyzedAt":"2026-08-18T17:04:10.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}