How to remote debugging on a vagrant machine? #303
-
Hello! I'm trying to remote debugging on my vagrant machine (which runs on my local machine).
I'd like to use the port This is my call plug#begin('~/.vim/plugged')
" ...
Plug 'mfussenegger/nvim-dap'
Plug 'theHamsta/nvim-dap-virtual-text'
Plug 'rcarriga/nvim-dap-ui'
" ...
call plug#end()
" ...
source ~/.config/nvim/plugins/dap.vim This is the augroup NvimDap
autocmd!
au FileType dap-repl lua require('dap.ext.autocompl').attach()
augroup END
let g:my_dap_repl_is_open = v:false
function OpenRepl()
echo "called"
" open repl if it isn't opened yet
if !g:my_dap_repl_is_open
lua require('dap').repl.open()
let g:my_dap_repl_is_open = v:true
endif
lua require('dap').continue()
endfunction
nnoremap <F5> :call OpenRepl()<CR>
nnoremap <F6> :lua require('dap').step_over()<CR>
nnoremap <F7> :lua require('dap').step_into()<CR>
nnoremap <F8> :lua require('dap').step_out()<CR>
nnoremap <F9><F9> :lua require('dap').toggle_breakpoint()<CR>
nnoremap <F9><F10> :lua require('dap').set_breakpoint(vim.fn.input('Breakpoint condition: '))<CR>
nnoremap <F9><F7> :lua require('dap').set_breakpoint(nil, nil, vim.fn.input('Log point message: '))<CR>
"nnoremap <silent> <leader>dl :lua require'dap'.run_last()<CR>
lua require("dap_conf") And this is in my local dap = require('dap')
local dap_ui = require('dapui')
dap.set_log_level('TRACE')
dap_ui.setup(
{
icons = {
expanded = "⯆",
collapsed = "⯈",
circular = "↺"
},
mappings = {
expand = "<CR>",
open = "o",
remove = "d"
},
sidebar = {
elements = {
-- You can change the order of elements in the sidebar
"scopes",
"stacks",
"watches"
},
width = 40,
position = "left" -- Can be "left" or "right"
},
tray = {
elements = {
"repl"
},
height = 10,
position = "bottom" -- Can be "bottom" or "top"
},
floating = {
max_height = nil, -- These can be integers or a float between 0 and 1.
max_width = nil -- Floats will be treated as percentage of your screen.
}
})
vim.g.dap_virtual_text = true
-- DAP CONFIG --
dap.adapters.python_local = {
type = 'executable';
command = 'python3';
args = {'-m', 'debugpy.adapter'};
}
dap.adapters.python_remote = {
type = 'server';
host = '127.0.0.1';
port = 5678;
}
dap.configurations.python = {
{
name = 'Remote file';
type = 'python_remote';
request = 'attach';
},
{
name = 'Launch file';
type = 'python_local';
request = 'launch';
program = '${file}';
},
} Reproduction steps
a = 10
b = 100
print(a + b)
Actual BehaviourI'm getting the following output:
Since I set
Expected behaviourA starting debugging session. Other informationIf I run |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
If you change the vagrant configuration to:
and start debugpy with Two other unrelated remarks:
|
Beta Was this translation helpful? Give feedback.
If you change the vagrant configuration to:
and start debugpy with
python -m debugpy --listen 0.0.0.0:5678 --wait-for-client /tmp/test.py
it should work.Vagrant (or rather, virtualbox if using the default provider) sets up some 10.0.x.y interface for communication from host to guest system. If you start debugpy with
--listen 5678
it will bind to127.0.0.1
in the guest and the host won't be able to communicate with it. Using0.0.0.0:5678
ensures that it will bind the debugpy…