siyuan-note/siyuan · error · ErrPandocNotFound

not found executable pandoc

Error message

not found executable pandoc

What it means

ErrPandocNotFound is the sentinel error returned when the pandoc executable cannot be located or when running in a container where pandoc is unavailable. GetPandocRuntime().BinPath is empty when pandoc is not installed or not on PATH, and ContainerStd != Container means the deployment container lacks the pandoc bundle.

Solutions

  1. Install pandoc on the host and ensure its directory is in the kernel process PATH
  2. Restart the kernel after installing so GetPandocRuntime() re-detects the binary
  3. If using containers, switch to the image variant that bundles pandoc or add pandoc to the image
  4. Verify detection by checking that the pandoc command resolves before invoking SiYuan

Example fix

// before (error returned)
out, err := api.ConvertClipboardMath(...) // util.ErrPandocNotFound
// after (ensure pandoc present)
# apt-get install -y pandoc  (or download from pandoc.org and add to PATH)
# restart SiYuan kernel, then retry the conversion
Defensive patterns

Strategy: fallback

Validate before calling

if runtime.GOOS != "windows" {
  if _, err := exec.LookPath("pandoc"); err != nil {
    return errors.New("pandoc is required but not found on PATH")
  }
}

Try / catch

path, err := util.Pandoc(args...)
if errors.Is(err, util.ErrPandocNotFound) {
  // degrade gracefully: skip pandoc-based conversion, inform user to install pandoc
  return nil, fmt.Errorf("pandoc unavailable: %w", err)
}

Prevention

When it happens

Trigger: Calling util.Pandoc / ConvertPandoc or the clipboard-math API (kernel/api/lute_clipboard_math.go:328) when pandoc was never found on the system or the kernel runs in the standard container image without pandoc.

Common situations: Pandoc not installed on the host; pandoc installed but not in the kernel process PATH; running the Docker image variant that ships without pandoc; broken pandoc install after an OS upgrade.

Related errors


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

Appendix: source

Thrown at kernel/util/pandoc.go:33

// along with this program.  If not, see <https://www.gnu.org/licenses/>.

package util

import (
	"bytes"
	"errors"
	"os"
	"os/exec"
	"path/filepath"
	"runtime"
	"strings"
	"sync"

	"github.com/88250/gulu"
	"github.com/siyuan-note/logging"
)

var ErrPandocNotFound = errors.New("not found executable pandoc")

func ConvertPandoc(dir string, args ...string) (path string, err error) {
	pandocBinPath := GetPandocRuntime().BinPath
	if "" == pandocBinPath || ContainerStd != Container {
		err = ErrPandocNotFound
		return
	}

	pandoc := exec.Command(pandocBinPath, args...)
	gulu.CmdAttr(pandoc)
	path = filepath.Join("temp", "convert", "pandoc", dir)
	absPath := filepath.Join(WorkspaceDir, path)
	if err = os.MkdirAll(absPath, 0755); err != nil {
		logging.LogErrorf("mkdir [%s] failed: [%s]", absPath, err)
		return
	}
	pandoc.Dir = absPath
	output, err := pandoc.CombinedOutput()

View on GitHub (pinned to 9f775e8a12)