Skip to content

How to Fix Emacs DAP Mode Errors — Debugger Adapter Protocol Issues

DodaTech Updated 2026-06-24 1 min read

In this tutorial, you'll learn about How to Fix Emacs DAP Mode Errors. We cover key concepts, practical examples, and best practices.

The Problem

DAP mode fails to start debugging:

dap-mode: Unable to find a debugger for this buffer

Quick Fix

Step 1: Install a debug adapter

pip install debugpy
npm install -g vscode-js-debug
go install github.com/go-delve/delve/cmd/dlv@latest
sudo apt install lldb-14

Step 2: Configure DAP mode

(use-package dap-mode
  :ensure t
  :after lsp-mode
  :config
  (dap-mode t)
  (dap-ui-mode t)
  (require 'dap-python)
  (require 'dap-gdb-lldb))

Step 3: Create a debug configuration

M-x dap-debug

Select a template and fill in program name, arguments, and working directory.

Or create a .vscode/launch.json:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Python: Current File",
      "type": "python",
      "request": "launch",
      "program": "${file}]
    }
  ]
}

Step 4: Set and manage breakpoints

M-x dap-breakpoint-toggle
M-x dap-breakpoint-list

Step 5: Control the debugger

M-x dap-continue
M-x dap-next
M-x dap-step-in
M-x dap-disconnect

Prevention

  • Install the debug adapter before using DAP mode.
  • Create a .vscode/launch.json for your projects.
  • Keep dap-mode and lsp-mode updated.

Common Mistakes with dap mode

  1. Using return to exit a function early instead of wrapping a pure value in the monad
  2. Mixing let bindings with <- bindings in do notation, producing type errors
  3. Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors

These mistakes appear frequently in real-world EMACS code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### What is the difference between DAP mode and realgud?

DAP mode implements the Debug Adapter Protocol (same as VS Code). Realgud works with GDB, LLDB, and other debuggers directly.

How do I debug a Python script with DAP mode?

Install debugpy, open a Python file, set breakpoints, and run M-x dap-debug.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro