Skip to content

Index out of range error when line or file holding breakpoint gets deleted #941

@dkaszews

Description

@dkaszews

Description

Vimspector cannot handle breakpoint on a line which no longer exists because the file has been truncated, renamed or deleted.

Suggested fix is to put a try/except in correct place, then prompt the user if they want to delete the breakpoint or keep it inactive for later.

Is it reproducible in vim?

Reproducible in Vim

Works with clean config?

Yes

Sample project works?

Reproducible with sample project

Minimal Reproduction

  1. Open any file supported by vimspector
  2. Place a breakpoint
  3. Delete or rename the file
  4. Run :VimspectorBreakpoints

Alt repro:
2. Place a breakpoint near end of the file
3. Truncate file so the breakpoint disappears, e.g. it was on line 100 but file now only has 90 lines

Expected Behaviour

No error, breakpoint should be removed or become inactive

Actual Behaviour

Error trace shown below. Similar error also appears without running the :VimspectorBreakpoints command, e.g. when navigating netrw or switching active buffers, but less reliable. Due to inability to open breakpoints view, only fix is to restart vim.

Additional information

Errors:

Error detected while processing function vimspector#ListBreakpoints[4]..provider#python3#Call:
line    1:
E5108: Error executing lua Vim:Error invoking 'python_execute' on channel 3 (python3-script-host):
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    import sys; sys.path = [p for p in sys.path if p != ""]; import neovim; neovim.start_host()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dkaszews/.local/share/nvim/plugged/vimspector/python3/vimspector/debug_session.py", line 2226, in ListBreakpoints
    self._breakpoints.ToggleBreakpointsView()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/dkaszews/.local/share/nvim/plugged/vimspector/python3/vimspector/breakpoints.py", line 294, in ToggleBreakpointsView
    self._breakpoints_view.ToggleBreakpointView( self.BreakpointsAsQuickFix() )
                                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/dkaszews/.local/share/nvim/plugged/vimspector/python3/vimspector/breakpoints.py", line 450, in BreakpointsAsQuickFix
    line_value = utils.BufferLineValue( file_name, line )
  File "/home/dkaszews/.local/share/nvim/plugged/vimspector/python3/vimspector/utils.py", line 89, in BufferLineValue
    return buf[ line_num - 1 ]
           ~~~^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/pynvim/api/buffer.py", line 78, in __getitem__
    return self.request('nvim_buf_get_lines', i, i + 1, True)[0]
           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/pynvim/api/common.py", line 80, in request
    return self._session.request(name, self, *args, **kwargs)
           ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/pynvim/api/nvim.py", line 211, in request
    res = self._session.request(name, *args, **kwargs)
  File "/usr/lib/python3.13/site-packages/pynvim/msgpack_rpc/session.py", line 142, in request
    raise self.error_wrapper(err)
pynvim.api.common.NvimError: Index out of bounds
stack traceback:
        [C]: at 0x558de4622900

Installation Type

Plugin Manager (git clone)

Vimspector version

a1ee02d

Debug Info

Vimspector not connected, start a debug session first


Repro does not require starting a session.

Log file

2025-09-13 21:04:46,467 - INFO - debug_session.py:140 - 0 - **** INITIALISING NEW VIMSPECTOR SESSION FOR ID 0 ****
2025-09-13 21:04:46,467 - INFO - debug_session.py:142 - 0 - API is: neo
2025-09-13 21:04:46,467 - INFO - debug_session.py:143 - 0 - VIMSPECTOR_HOME = /home/dkaszews/.local/share/nvim/plugged/vimspector/python3/vimspector/../..
2025-09-13 21:04:46,467 - INFO - debug_session.py:144 - 0 - gadgetDir = /home/dkaszews/.local/share/nvim/plugged/vimspector/gadgets/linux

Vim version

NVIM v0.11.3
Build type: RelWithDebInfo
LuaJIT 2.1.1753364724
Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions     -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security     -fstack-clash-protection -fcf-protection     -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/build/neovim/src=/usr/src/debug/neovim -flto=auto -O2 -g -flto=auto -fno-fat-lto-objects -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wvla -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -fsigned-char -fstack-protector-strong -Wno-conversion -fno-common -Wno-unused-result -Wimplicit-fallthrough -fdiagnostics-color=always  -DUNIT_TESTING -D_GNU_SOURCE -DINCLUDE_GENERATED_DECLARATIONS -DUTF8PROC_STATIC -I/usr/include/luajit-2.1 -I/usr/include -I/build/neovim/src/neovim/build/src/nvim/auto -I/build/neovim/src/neovim/build/include -I/build/neovim/src/neovim/build/cmake.config -I/build/neovim/src/neovim/src 

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

Python version

No response

Neovim diagnostics

==============================================================================
vim.deprecated:                                                             ✅

- ✅ OK No deprecated functions detected

==============================================================================
vim.health:                                                               1 ⚠️

Configuration ~
- ✅ OK no issues found

Runtime ~
- ✅ OK $VIMRUNTIME: /usr/share/nvim/runtime

Performance ~
- ✅ OK Build type: RelWithDebInfo

Remote Plugins ~
- ✅ OK Up to date

terminal ~
- key_backspace (kbs) terminfo entry: `key_backspace=\177`
- key_dc (kdch1) terminfo entry: `key_dc=\E[3~`
- $COLORTERM="truecolor"

External Tools ~
- ⚠️ WARNING ripgrep not available

==============================================================================
vim.lsp:                                                                    ✅

- LSP log level : WARN
- Log path: /home/dkaszews/.local/state/nvim/lsp.log
- Log size: 0 KB

vim.lsp: Active Clients ~
- No active clients

vim.lsp: Enabled Configurations ~

vim.lsp: File Watcher ~
- file watching "(workspace/didChangeWatchedFiles)" disabled on all clients

vim.lsp: Position Encodings ~
- No active clients

==============================================================================
vim.provider:                                                             5 ⚠️

Clipboard (optional) ~
- ✅ OK Clipboard tool found: xclip

Node.js provider (optional) ~
- ⚠️ WARNING `node` and `npm` (or `yarn`, `pnpm`) must be in $PATH.
  - ADVICE:
    - Install Node.js and verify that `node` and `npm` (or `yarn`, `pnpm`) commands work.

Perl provider (optional) ~
- ⚠️ WARNING "Neovim::Ext" cpan module is not installed
  - ADVICE:
    - See :help |provider-perl| for more information.
    - You can disable this provider (and warning) by adding `let g:loaded_perl_provider = 0` to your init.vim
- ⚠️ WARNING No usable perl executable found

Python 3 provider (optional) ~
- `g:python3_host_prog` is not set. Searching for python3 in the environment.
- Executable: /usr/bin/python3
- Python version: 3.13.7
- pynvim version: 0.5.2 (outdated; from /usr/lib/python3.13/site-packages/neovim)
- ⚠️ WARNING Latest pynvim is NOT installed: 0.6.0

Python virtualenv ~
- ✅ OK no $VIRTUAL_ENV

Ruby provider (optional) ~
- ⚠️ WARNING `ruby` and `gem` must be in $PATH.
  - ADVICE:
    - Install Ruby and verify that `ruby` and `gem` commands work.

==============================================================================
vim.treesitter:                                                             ✅

Treesitter features ~
- Treesitter ABI support: min 13, max 15
- WASM parser support: false

Treesitter parsers ~
- ✅ OK Parser: c                    ABI: 15, path: /usr/share/nvim/runtime/parser/c.so
- ✅ OK Parser: lua                  ABI: 15, path: /usr/share/nvim/runtime/parser/lua.so
- ✅ OK Parser: markdown             ABI: 15, path: /usr/share/nvim/runtime/parser/markdown.so
- ✅ OK Parser: markdown_inline      ABI: 15, path: /usr/share/nvim/runtime/parser/markdown_inline.so
- ✅ OK Parser: query                ABI: 15, path: /usr/share/nvim/runtime/parser/query.so
- ✅ OK Parser: vim                  ABI: 15, path: /usr/share/nvim/runtime/parser/vim.so
- ✅ OK Parser: vimdoc               ABI: 15, path: /usr/share/nvim/runtime/parser/vimdoc.so

Operating System

Linux Cuddles-Bobba 6.16.2-arch1-1 #1 SMP PREEMPT_DYNAMIC Wed, 20 Aug 2025 21:43:45 +0000 x86_64 GNU/Linux

Declaration

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions