mfussenegger / nvim-dap

Debug Adapter Protocol client implementation for Neovim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't debug haskell (cabal)

rekaerst opened this issue · comments

commented

Debug adapter definition and debug configuration

dap.adapters.haskell = {
	type = 'executable';
	command = 'haskell-debug-adapter';
}

dap.configurations.haskell = {{
	type = 'haskell',
	request = 'launch',
	name = 'haskell(cabal)',
	workspace = '${workspaceFolder}',
	startup = "${workspaceFolder}/app/Main.hs",
	stopOnEntry = false,
	logFile = vim.fn.stdpath('cache') .. '/haskell-dap.log',
	logLevel = 'WARNING',
	ghciEnv = vim.empty_dict(),
	ghciPrompt = "λ: ",
	ghciInitialPrompt = "λ: ",
	ghciCmd = "cabal exec -- ghci-dap --interactive -i -i${workspaceFolder}",
}}

Debug adapter version

0.0.33.0

Steps to Reproduce

  1. Setup project
$ mkdir project_cabal
$ cd project_cabal
$ cabal init
$ cabal configure
$ cabal bulid
  1. run continue()

Expected Result

nothing funny happens

Actual Result

Debug adapter didn't respond. Either the adapter is slow (then wait and ignore this) or there is a problem with your a
dapter or `haskell` configuration. Check the logs for errors (:help dap.set_log_level)

Log

  • dap-repl

Configuration read.
Starting GHCi.
Wait for a moment.

CWD: /home/arthur/tmp/test
CMD: cabal exec -- ghci-dap --interactive -i -i/home/arthur/tmp/test

Now, waiting for an initial prompt("λ: ") from ghci.

  • dap.log
[ DEBUG ] 2022-03-16T19:07:17Z+0800 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:715 ]	"Spawning debug adapter"	{
  command = "haskell-debug-adapter",
  type = "executable"
}
[ DEBUG ] 2022-03-16T19:07:17Z+0800 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:887 ]	"request"	{
  arguments = {
    adapterID = "nvim-dap",
    clientId = "neovim",
    clientname = "neovim",
    columnsStartAt1 = true,
    linesStartAt1 = true,
    locale = "en_US.UTF-8",
    pathFormat = "path",
    supportsRunInTerminalRequest = true,
    supportsVariableType = true
  },
  command = "initialize",
  seq = 0,
  type = "request"
}
[ DEBUG ] 2022-03-16T19:07:17Z+0800 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:563 ]	{
  body = {
    additionalModuleColumns = {},
    exceptionBreakpointFilters = {},
    supportsCompletionsRequest = true,
    supportsConditionalBreakpoints = true,
    supportsConfigurationDoneRequest = true,
    supportsEvaluateForHovers = true,
    supportsFunctionBreakpoints = true,
    supportsGotoTargetsRequest = false,
    supportsHitConditionalBreakpoints = true,
    supportsLogPoints = true,
    supportsModulesRequest = false,
    supportsRestartFrame = false,
    supportsSetVariable = false,
    supportsStepBack = false,
    supportsStepInTargetsRequest = false,
    supportsTerminateRequest = true
  },
  command = "initialize",
  message = "",
  request_seq = 0,
  seq = 1,
  success = true,
  type = "response"
}
[ DEBUG ] 2022-03-16T19:07:17Z+0800 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:887 ]	"request"	{
  arguments = {
    ghciCmd = "cabal exec -- ghci-dap --interactive -i -i/home/arthur/tmp/test",
    ghciEnv = vim.empty_dict(),
    ghciInitialPrompt = "λ: ",
    ghciPrompt = "λ: ",
    logFile = "/home/arthur/.cache/nvim/haskell-dap.log",
    logLevel = "WARNING",
    name = "haskell(cabal)",
    request = "launch",
    startup = "/home/arthur/tmp/test/app/Main.hs",
    stopOnEntry = false,
    type = "haskell",
    workspace = "/home/arthur/tmp/test"
  },
  command = "launch",
  seq = 1,
  type = "request"
}
[ DEBUG ] 2022-03-16T19:07:17Z+0800 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:563 ]	{
  body = {
    category = "stdout",
    output = "Configuration read.\n"
  },
  event = "output",
  seq = 2,
  type = "event"
}
[ DEBUG ] 2022-03-16T19:07:17Z+0800 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:563 ]	{
  body = {
    category = "console",
    output = "Starting GHCi.\n"
  },
  event = "output",
  seq = 3,
  type = "event"
}
[ DEBUG ] 2022-03-16T19:07:17Z+0800 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:563 ]	{
  body = {
    category = "stderr",
    output = "Wait for a moment.\n\n"
  },
  event = "output",
  seq = 4,
  type = "event"
}
[ DEBUG ] 2022-03-16T19:07:17Z+0800 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:563 ]	{
  body = {
    category = "console",
    output = "CWD: /home/arthur/tmp/test\n"
  },
  event = "output",
  seq = 5,
  type = "event"
}
[ DEBUG ] 2022-03-16T19:07:17Z+0800 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:563 ]	{
  body = {
    category = "console",
    output = "CMD: cabal exec -- ghci-dap --interactive -i -i/home/arthur/tmp/test\n"
  },
  event = "output",
  seq = 6,
  type = "event"
}
[ DEBUG ] 2022-03-16T19:07:17Z+0800 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:563 ]	{
  body = {
    category = "console",
    output = "\n"
  },
  event = "output",
  seq = 7,
  type = "event"
}
[ DEBUG ] 2022-03-16T19:07:17Z+0800 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:563 ]	{
  body = {
    category = "stderr",
    output = 'Now, waiting for an initial prompt("λ: ") from ghci.\n'
  },
  event = "output",
  seq = 8,
  type = "event"
}
[ DEBUG ] 2022-03-16T19:07:17Z+0800 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:563 ]	{
  body = {
    category = "console",
    output = "\n"
  },
  event = "output",
  seq = 9,
  type = "event"
}
[ DEBUG ] 2022-03-16T19:11:08Z+0800 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:887 ]	"request"	{
  arguments = vim.empty_dict(),
  command = "terminate",
  seq = 2,
  type = "request"
}

Have you tried changing the log level to debug or error?
I think the haskell-debug-adapter also writes output to the dap-repl

commented

Sorry, I forgot to mention that only the haskell-dap.log is empty.
Updated the description.

How does your ghci prompt really look like?

The entry

output = 'Now, waiting for an initial prompt("λ: ") from ghci.\n'

followed by not much else makes me thing it doesn't find it.

As described in the wiki, you need to adapt the prompt to whatever you've configured in your .ghci.conf:

 -- Adjust the prompt to the prompt you see when you invoke the stack ghci command below 
    ghciInitialPrompt = "λ: ",
commented

As described in the wiki, you need to adapt the prompt to whatever you've configured in your .ghci.conf:

Thanks a lot. I changed ghciInitialPrompt to "> " and ghci can be started (perhaps wiki should use ghciInitialPrompt = "> " since the default ghci prompt is "ghci> "?)

However, I got a new error.

<interactive>:8:1: error:
    • Variable not in scope: main
    • Perhaps you meant ‘min’ (imported from Prelude)
H>>= 
start debugging failed. user error (ExecResult not found.) : Left "user error (ExecResult not found.)"

Sounds like an issue with the debug adapter, not a client specific nvim-dap issue. The maintainers of the debug adapter are probably better suited to help you.

commented

Sounds like an issue with the debug adapter

It probably isn't that the Haskell debug adapter has the issue
I've tested the same dap configuration with VSCode(no extension), Vimspector(no extension) and dap-mode only nvim-dap throw this error.

image
image