kdheepak / nvim-dap-julia

MIT License
13 stars 0 forks source link

DAP Couldn't connect to 127.0.0.1:${port}: ECONNREFUSED #3

Open arnold-c opened 2 months ago

arnold-c commented 2 months ago

Unfortunately I'm not able to get this to work on my laptop (Macbook M1, Sonoma 14.5) as it's resulting in ECONNREFUSED. I'm afraid I don't have much experience with the DAP protocol, so my trouble-shooting abilities are a little limited, but I have been able to get Delve (Go's DAP) running as expected. Other related issues I found in nvim-dap were related to localhost, but that doesn't seem to be the issue here as the default setup already uses 127.0.0.1 rather than localhost (https://github.com/mfussenegger/nvim-dap/issues/1031).

This is my current dap setup (based on kickstart.nvim), but I've also tried the configs listed in the README (both simple and advanced versions).

return {
  'mfussenegger/nvim-dap',
  dependencies = {
    -- Creates a beautiful debugger UI
    'rcarriga/nvim-dap-ui',
    'nvim-neotest/nvim-nio',
    'theHamsta/nvim-dap-virtual-text',

    -- Installs the debug adapters for you
    'williamboman/mason.nvim',
    'jay-babu/mason-nvim-dap.nvim',

    -- Add your own debuggers here
    'leoluz/nvim-dap-go',
    'kdheepak/nvim-dap-julia',
  },
  event = 'BufEnter',
  config = function()
    local dap = require 'dap'
    local dapui = require 'dapui'

    dapui.setup()

    require('mason').setup {}
    nmap('<leader>vm', ':Mason<cr>', 'Mason')

    require('mason-nvim-dap').setup {
      -- Makes a best effort to setup the various debuggers with
      -- reasonable debug configurations
      automatic_installation = true,

      -- You can provide additional configuration to the handlers,
      -- see mason-nvim-dap README for more information
      handlers = {},

      -- You'll need to check that you have the required things installed
      -- online, please don't ask me how to install them :)
      ensure_installed = {
        -- Update this to ensure that you have the debuggers for the langs you want
        'delve',
      },
    }

    -- Basic debugging keymaps, feel free to change to your liking!
    nmap('<leader>dB', function()
      dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ')
    end, 'Breakpoint Condition')
    nmap('<leader>db', dap.toggle_breakpoint, 'Toggle Breakpoint')
    nmap('<leader>dc', dap.continue, 'Continue')
    nmap('<leader>da', function()
      local get_args = vim.fn.input 'Args: '
      dap.continue { before = get_args }
    end, 'Run with Args')
    nmap('<leader>dC', dap.run_to_cursor, 'Run to Cursor')
    nmap('<leader>dg', dap.goto_, 'Go to line (no execute)')
    nmap('<leader>di', dap.step_into, 'Step Into')
    nmap('<leader>dj', dap.down, 'down')
    nmap('<leader>dk', dap.up, 'Up')
    nmap('<leader>dl', dap.run_last, 'Run Last')
    nmap('<leader>do', dap.step_out, 'Step Out')
    nmap('<leader>dO', dap.step_over, 'Step Over')
    nmap('<leader>dp', dap.pause, 'Pause')
    nmap('<leader>dr', dap.repl.toggle, 'Toggle REPL')
    nmap('<leader>ds', dap.session, 'Session')
    nmap('<leader>dt', dap.terminate, 'Terminate')

    -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception.
    nmap('<leader>dL', dapui.toggle, 'Debug: See last session result.')

    dap.listeners.after.event_initialized['dapui_config'] = dapui.open
    dap.listeners.before.event_terminated['dapui_config'] = dapui.close
    dap.listeners.before.event_exited['dapui_config'] = dapui.close

    -- Install language specific config
    require('dap-go').setup()

    require('nvim-dap-julia').setup()
  end,
}

Thanks for putting this together - looking forward to being able to use the DAP in nvim.

SoichiroYamane commented 4 weeks ago

I also got the same error in Macbook M1 Sonoma 14.5, but I found a tentative solution for this issue. Although scripts/server.jl describes

using Pkg
Pkg.instantiate()

, I've tried to install dependencies manually.

  1. Open julia repl in nvim-dap-julia directory:
    julia --project=~/.local/share/nvim/lazy/nvim-dap-julia
  2. Install dependencies
    using Pkg
    Pkg.instantiate() 

    After this installation, I got to run the julia debugger.

Here is my config for nvim-dap-julia using lazy.nvim

  {
    "kdheepak/nvim-dap-julia",
    ft = "julia",
    config = function()
      local nvim_dap_julia = require("nvim-dap-julia")
      nvim_dap_julia.setup({})
    end,
  },

I hope you find this information useful.

arnold-c commented 2 weeks ago

That worked - thanks @SoichiroYamane! I'll leave this open for the moment, as it requires a little more work than the usual setup, though feel free to close (I can add this information to the README if no changes are to be made at the moment).