You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Emacs中Markdown预览失败:报错exit code 127(疑似Pandoc问题)

Troubleshooting "markdown failed with exit code 127" in Emacs Markdown Mode

Hey there, let's walk through your problem step by step—since you're new to Emacs, I'll keep things clear and actionable.

1. What does exit code 127 mean, and how to get more detailed error info?

On Unix-like systems (including macOS), exit code 127 is a standard error that means the shell can't locate the command Emacs is trying to run. In this case, Markdown Mode is attempting to call a tool named markdown, but your system doesn't have it available.

To get more detailed error messages:

  • Press M-! (Alt+!) to open Emacs' shell command prompt, type markdown and hit Enter. The output here will explicitly say "command not found" or similar, confirming the issue.
  • Check the Messages buffer in Emacs: press C-x b *Messages* to open it—this buffer logs most Emacs actions, so you might find additional context about why the command failed.

2. Why does this happen even though you have Pandoc installed?

Markdown Mode supports multiple conversion tools (Pandoc, markdown, MultiMarkdown, etc.), but its default setting is to look for a command named markdown, not pandoc. Since you only have Pandoc installed, the system can't find the markdown command, hence the 127 error.

3. How to fix this, and which docs to reference?

You have two straightforward solutions:

Option 1: Configure Markdown Mode to use Pandoc

Edit your Emacs configuration file (usually ~/.emacs or ~/.emacs.d/init.el) and add this line:

(setq markdown-command "pandoc")
  • Save the file, then restart Emacs or run M-x eval-buffer to apply the change immediately. Now when you trigger preview, Emacs will use Pandoc instead of looking for the markdown command.

Option 2: Install the markdown command

If you prefer to use the original markdown tool (instead of Pandoc), install it via Homebrew:

brew install markdown

Once installed, the preview command should work without needing to change your Emacs config.

  • Markdown Mode's built-in docs: Press M-x describe-package markdown-mode—this will show you all available configuration options, including details about markdown-command.
  • Graphical customization: Run M-x customize-group markdown to open a user-friendly interface where you can set the markdown command (and other options) without editing config files directly.

As a quick tip for new Emacs users: always back up your config file before making changes, so you can revert if something goes wrong.

内容的提问来源于stack exchange,提问作者patrick

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 07:27:11