Issue Running Debugger on Tests: __debug_bin: no such file or directory #37

Closed
opened 2023-03-02 16:45:29 +03:00 by pjkaufman · 6 comments
pjkaufman commented 2023-03-02 16:45:29 +03:00 (Migrated from github.com)

I am having some trouble running nvim-dap-go. It is likely a config error, but I have not been able to figure out what is wrong with how I am setting things up so I decided to open an issue and see if someone knows what I am doing wrong.

Setup:

local dap_status_ok, dap = pcall(require, "dap")
if not dap_status_ok then
	return
end

local dap_ui_status_ok, dapui = pcall(require, "dapui")
if not dap_ui_status_ok then
	return
end

-- local dap_install_status_ok, dap_install = pcall(require, "dap-install")
-- if not dap_install_status_ok then
-- return
-- end

local dap_go_status_ok, dap_go = pcall(require, "dap-go")
if not dap_go_status_ok then
	return
end

local dap_vt_status_ok, dap_vt = pcall(require, "nvim-dap-virtual-text")
if not dap_vt_status_ok then
	return
end
-- dap_install.setup({})
dap_go.setup({
	-- Additional dap configurations can be added.
	-- dap_configurations accepts a list of tables where each entry
	-- represents a dap configuration. For more details do:
	-- :help dap-configuration
	dap_configurations = {
		{
			-- Must be "go" or it will be ignored by the plugin
			type = "go",
			name = "Attach remote",
			mode = "remote",
			request = "attach",
		},
	},
	-- delve configurations
	delve = {
		-- time to wait for delve to initialize the debug session.
		-- default to 20 seconds
		initialize_timeout_sec = 20,
		-- a string that defines the port to start delve debugger.
		-- default to string "${port}" which instructs nvim-dap
		-- to start the process in a random available port
		port = "${port}",
	},
})
dap_vt.setup()

-- dap_install.config("python", {})
-- add other configs here

dapui.setup({
	expand_lines = true,
	icons = { expanded = "", collapsed = "", circular = "" },
	mappings = {
		-- Use a table to apply multiple mappings
		expand = { "<CR>", "<2-LeftMouse>" },
		open = "o",
		remove = "d",
		edit = "e",
		repl = "r",
		toggle = "t",
	},
	layouts = {
		{
			elements = {
				{ id = "scopes", size = 0.33 },
				{ id = "breakpoints", size = 0.17 },
				{ id = "stacks", size = 0.25 },
				{ id = "watches", size = 0.25 },
			},
			size = 0.33,
			position = "right",
		},
		{
			elements = {
				{ id = "repl", size = 0.45 },
				{ id = "console", size = 0.55 },
			},
			size = 0.27,
			position = "bottom",
		},
	},
	floating = {
		max_height = 0.9,
		max_width = 0.5, -- Floats will be treated as percentage of your screen.
		border = vim.g.border_chars, -- Border style. Can be 'single', 'double' or 'rounded'
		mappings = {
			close = { "q", "<Esc>" },
		},
	},
})

vim.fn.sign_define("DapBreakpoint", { text = "", texthl = "DiagnosticSignError", linehl = "", numhl = "" })

dap.listeners.after.event_initialized["dapui_config"] = function()
	dapui.open()
end

dap.listeners.before.event_terminated["dapui_config"] = function()
	dapui.close()
end

dap.listeners.before.event_exited["dapui_config"] = function()
	dapui.close()
end

dap.set_log_level("TRACE")

Note: dap_go.setup({}) does not work either

My go lsp config:

-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/gopls.lua
return {
	cmd = { "gopls"},
	settings = {
		gopls = {
      buildFlags = { "-tags=unit integration" },
      usePlaceholders = false,
			analyses = {
				nilness = true,
				shadow = true,
				unusedparams = true,
				unusewrites = true,
			},
      staticcheck = true,
		},
	},
}

Keymaps:

-- DAP
keymap("n", "<leader>db", "<cmd>lua require'dap'.toggle_breakpoint()<cr>", opts)
keymap("n", "<leader>dc", "<cmd>lua require'dap'.continue()<cr>", opts)
keymap("n", "<leader>di", "<cmd>lua require'dap'.step_into()<cr>", opts)
keymap("n", "<leader>do", "<cmd>lua require'dap'.step_over()<cr>", opts)
keymap("n", "<leader>dO", "<cmd>lua require'dap'.step_out()<cr>", opts)
keymap("n", "<leader>dr", "<cmd>lua require'dap'.repl.toggle()<cr>", opts)
keymap("n", "<leader>dl", "<cmd>lua require'dap'.run_last()<cr>", opts)
keymap("n", "<leader>du", "<cmd>lua require'dapui'.toggle()<cr>", opts)
keymap("n", "<leader>dq", "<cmd>lua require'dap'.terminate()<cr>", opts)
keymap("n", "<leader>dt", "<cmd>lua require'dap-go'.debug_test()<cr>", opts)

When I have my cursor in a test file and do <leader>dt I get the following in logs:

[ DEBUG ] 2023-03-02T08:28:05Z-0500 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:844 ]	{
  body = {
    error = {
      format = "Failed to launch: could not launch process: open $PATH/__debug_bin: no such file or directory",
      id = 3000,
      showUser = true
    }
  },
  command = "launch",
  message = "Failed to launch",
  request_seq = 1,
  seq = 0,
  success = false,
  type = "response"
}

I have swapped out the values path for $PATH in the above log.

I am not sure what other information would help with knowing what is wrong, but I know that running the following command works via command line: go test --tags unit ./...

Is there something I am doing wrong with my setup?

Please let me know if there are any pieces of information that would be helpful to include.

I am having some trouble running `nvim-dap-go`. It is likely a config error, but I have not been able to figure out what is wrong with how I am setting things up so I decided to open an issue and see if someone knows what I am doing wrong. Setup: ``` Lua local dap_status_ok, dap = pcall(require, "dap") if not dap_status_ok then return end local dap_ui_status_ok, dapui = pcall(require, "dapui") if not dap_ui_status_ok then return end -- local dap_install_status_ok, dap_install = pcall(require, "dap-install") -- if not dap_install_status_ok then -- return -- end local dap_go_status_ok, dap_go = pcall(require, "dap-go") if not dap_go_status_ok then return end local dap_vt_status_ok, dap_vt = pcall(require, "nvim-dap-virtual-text") if not dap_vt_status_ok then return end -- dap_install.setup({}) dap_go.setup({ -- Additional dap configurations can be added. -- dap_configurations accepts a list of tables where each entry -- represents a dap configuration. For more details do: -- :help dap-configuration dap_configurations = { { -- Must be "go" or it will be ignored by the plugin type = "go", name = "Attach remote", mode = "remote", request = "attach", }, }, -- delve configurations delve = { -- time to wait for delve to initialize the debug session. -- default to 20 seconds initialize_timeout_sec = 20, -- a string that defines the port to start delve debugger. -- default to string "${port}" which instructs nvim-dap -- to start the process in a random available port port = "${port}", }, }) dap_vt.setup() -- dap_install.config("python", {}) -- add other configs here dapui.setup({ expand_lines = true, icons = { expanded = "", collapsed = "", circular = "" }, mappings = { -- Use a table to apply multiple mappings expand = { "<CR>", "<2-LeftMouse>" }, open = "o", remove = "d", edit = "e", repl = "r", toggle = "t", }, layouts = { { elements = { { id = "scopes", size = 0.33 }, { id = "breakpoints", size = 0.17 }, { id = "stacks", size = 0.25 }, { id = "watches", size = 0.25 }, }, size = 0.33, position = "right", }, { elements = { { id = "repl", size = 0.45 }, { id = "console", size = 0.55 }, }, size = 0.27, position = "bottom", }, }, floating = { max_height = 0.9, max_width = 0.5, -- Floats will be treated as percentage of your screen. border = vim.g.border_chars, -- Border style. Can be 'single', 'double' or 'rounded' mappings = { close = { "q", "<Esc>" }, }, }, }) vim.fn.sign_define("DapBreakpoint", { text = "", texthl = "DiagnosticSignError", linehl = "", numhl = "" }) dap.listeners.after.event_initialized["dapui_config"] = function() dapui.open() end dap.listeners.before.event_terminated["dapui_config"] = function() dapui.close() end dap.listeners.before.event_exited["dapui_config"] = function() dapui.close() end dap.set_log_level("TRACE") ``` _Note: `dap_go.setup({})` does not work either_ My go lsp config: ``` Lua -- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/gopls.lua return { cmd = { "gopls"}, settings = { gopls = { buildFlags = { "-tags=unit integration" }, usePlaceholders = false, analyses = { nilness = true, shadow = true, unusedparams = true, unusewrites = true, }, staticcheck = true, }, }, } ``` Keymaps: ``` Lua -- DAP keymap("n", "<leader>db", "<cmd>lua require'dap'.toggle_breakpoint()<cr>", opts) keymap("n", "<leader>dc", "<cmd>lua require'dap'.continue()<cr>", opts) keymap("n", "<leader>di", "<cmd>lua require'dap'.step_into()<cr>", opts) keymap("n", "<leader>do", "<cmd>lua require'dap'.step_over()<cr>", opts) keymap("n", "<leader>dO", "<cmd>lua require'dap'.step_out()<cr>", opts) keymap("n", "<leader>dr", "<cmd>lua require'dap'.repl.toggle()<cr>", opts) keymap("n", "<leader>dl", "<cmd>lua require'dap'.run_last()<cr>", opts) keymap("n", "<leader>du", "<cmd>lua require'dapui'.toggle()<cr>", opts) keymap("n", "<leader>dq", "<cmd>lua require'dap'.terminate()<cr>", opts) keymap("n", "<leader>dt", "<cmd>lua require'dap-go'.debug_test()<cr>", opts) ``` When I have my cursor in a test file and do `<leader>dt` I get the following in logs: ``` [ DEBUG ] 2023-03-02T08:28:05Z-0500 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:844 ] { body = { error = { format = "Failed to launch: could not launch process: open $PATH/__debug_bin: no such file or directory", id = 3000, showUser = true } }, command = "launch", message = "Failed to launch", request_seq = 1, seq = 0, success = false, type = "response" } ``` I have swapped out the values path for `$PATH` in the above log. I am not sure what other information would help with knowing what is wrong, but I know that running the following command works via command line: ` go test --tags unit ./...` Is there something I am doing wrong with my setup? Please let me know if there are any pieces of information that would be helpful to include.
xD-saleem commented 2023-04-16 20:17:13 +03:00 (Migrated from github.com)

I also face the same issue.
starting debug session './lambdas/adjuster : TestSuite_Adjuster'... Error on launch: Failed to launch: could not launch process: open /home/slim/repos/svi/__debug_bin: no such file or directory

I also face the same issue. ` starting debug session './lambdas/adjuster : TestSuite_Adjuster'... Error on launch: Failed to launch: could not launch process: open /home/slim/repos/svi/__debug_bin: no such file or directory `
leoluz commented 2023-05-19 21:26:01 +03:00 (Migrated from github.com)

I am not sure but it seems dap is having problems compiling your project. Have you tried asking in the nvim-dap project?

I am not sure but it seems dap is having problems compiling your project. Have you tried asking in the [nvim-dap](https://github.com/mfussenegger/nvim-dap) project?
pjkaufman commented 2023-05-19 22:44:36 +03:00 (Migrated from github.com)

I have not opened an issue there as I was not aware that that would be the root cause of the problem.

I have not opened an issue there as I was not aware that that would be the root cause of the problem.
leoluz commented 2023-05-19 23:14:49 +03:00 (Migrated from github.com)

You can try running the test and after you get the error run :DapShowLog. Maybe you find useful info there.

You can try running the test and after you get the error run `:DapShowLog`. Maybe you find useful info there.
stale[bot] commented 2023-11-16 00:48:55 +03:00 (Migrated from github.com)

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
leoluz commented 2023-11-29 01:19:25 +03:00 (Migrated from github.com)

If someone else is having this problem, please take a look at this similar issue:
https://github.com/golang/vscode-go/issues/2234

If someone else is having this problem, please take a look at this similar issue: https://github.com/golang/vscode-go/issues/2234
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
NeonXP/nvim-dap-go#37
No description provided.