{"record":{"id":"b76538b1a23a55b3","repo":"siyuan-note/siyuan","slug":"pandoc-convert-failed-joined-command-error-and-raw-output","errorCode":null,"errorMessage":"pandoc convert failed (joined command error and raw output)","messagePattern":"pandoc convert failed \\(joined command error and raw output\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/util/pandoc.go","lineNumber":53,"sourceCode":"func 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()\n\tif err != nil {\n\t\terr = errors.Join(err, errors.New(string(output)))\n\t\tlogging.LogErrorf(\"pandoc convert output failed: %s\", err)\n\t\treturn\n\t}\n\tpath = \"/\" + filepath.ToSlash(path)\n\treturn\n}\n\nfunc Pandoc(from, to, o, content string) (err error) {\n\tif \"\" == from || \"\" == to || \"md\" == to {\n\t\tif err = gulu.File.WriteFileSafer(o, []byte(content), 0644); err != nil {\n\t\t\tlogging.LogErrorf(\"write export markdown file [%s] failed: %s\", o, err)\n\t\t}\n\t\treturn\n\t}\n\n\tpandocBinPath := GetPandocRuntime().BinPath\n\tif \"\" == pandocBinPath || ContainerStd != Container {\n\t\terr = ErrPandocNotFound","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/util/pandoc.go#L35-L71","documentation":"ConvertPandoc runs the pandoc binary on a directory and, when pandoc exits non-zero, joins the process error with pandoc's raw combined stdout/stderr output and returns it. The message signals that pandoc itself failed, and the joined value carries the underlying cause plus its raw output.","triggerScenarios":"pandoc.CombinedOutput() returns a non-zero exit status while converting a document — e.g. unsupported format flags, unreadable input files in the target directory, or malformed markdown inputs.","commonSituations":"Passing args unsupported by the installed pandoc version; input directory containing files pandoc cannot parse; pandoc failing due to missing LaTeX for PDF-related conversions; file permission problems in the working directory.","solutions":["Read the joined error: the second part is pandoc's raw output naming the real failure","Verify the installed pandoc version supports the flags used (pandoc --version)","Check the input directory contents and permissions","Install any missing pandoc dependencies (e.g. LaTeX for PDF exports) and retry"],"exampleFix":"// diagnosing\npath, err := util.ConvertPandoc(dir, args...)\nif err != nil {\n  log.Fatalf(\"pandoc failed: %v\", err) // joined: exit error + raw pandoc output\n}\n// fix: align args with pandoc version\n// before: args = [\"-f\", \"gfm+newfeature\", ...] // unknown extension on old pandoc\n// after:  args = [\"-f\", \"gfm\", ...]           // supported by installed pandoc","handlingStrategy":"try-catch","validationCode":"// pre-check inputs before invoking pandoc\nif err := os.Stat(dir); err != nil {\n  return fmt.Errorf(\"convert input dir missing: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"path, err := util.ConvertPandoc(dir, args...)\nif err != nil {\n  // err is errors.Join(exitErr, rawOutput) — log both parts\n  logging.LogErrorf(\"pandoc conversion failed for %s: %v\", dir, err)\n  return fmt.Errorf(\"pandoc conversion failed: %w\", err)\n}","preventionTips":["Match pandoc CLI flags to the installed pandoc version","Validate input directory contents and permissions before conversion","Install pandoc's optional dependencies (e.g. LaTeX) for PDF flows","Capture and inspect pandoc output in logs to pinpoint the real cause"],"tags":["pandoc","command-execution","export"],"backgroundTag":"command-not-found","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}