Giter Club home page Giter Club logo

Comments (17)

puremourning avatar puremourning commented on May 18, 2024 2

Here's how to make it work with debugpy :

Alternative: Use debugpy directly

If you can't get a node 10 envirinment set up for whatver reason, then you can
avoid that issue by using debugpy (formerly ptvsd directly).

Here's how:

  1. Instal debugpy: pip install debugpy
  2. Create /path/to/vimspector/gadgets/<os>/.gadgets.d/debugpy.json:
{
  "adapters": {
    "debugpy": {
      "command": [
        "python",
        "-m",
        "debugpy.adapter"
      ],
      "name": "debugpy",
      "configuration": {
        "python": "python"
      }
    }
  }
}

Then in theory you should just have to change "adapter": "vscode-python" to
"adapter": "debugpy".

I tested this and it works for me.

from vimspector.

puremourning avatar puremourning commented on May 18, 2024 1

#108 (comment)

It’s a(nother) neovim missing feature. Apparently it works with master but πŸ€·β€β™‚οΈ

from vimspector.

puremourning avatar puremourning commented on May 18, 2024 1

I pushed a PR to make it work in neovim. le sigh.

from vimspector.

puremourning avatar puremourning commented on May 18, 2024

You need to use node < 13. I recommend nvm use 10

This is a bug/incompatibility of the python debug adapter from Microsoft

from vimspector.

BlueDrink9 avatar BlueDrink9 commented on May 18, 2024

The debugger works in vscode though, is that expected with node > 13?

from vimspector.

puremourning avatar puremourning commented on May 18, 2024

I expect vscode is bundling node. You need a version of node that will run the DA.

from vimspector.

puremourning avatar puremourning commented on May 18, 2024

All vimspector is doing is running this:

"node" "/Users/eyalkarni/vimpy3/pack/vimspector/opt/vimspector/gadgets/macos/vscode-python/out/client/debugger/debugAdapter/main.js”

If you can see vscode doing something different let me know.

from vimspector.

puremourning avatar puremourning commented on May 18, 2024

re-opening as this doesn't affect VSCode and there's a meaninful possibility that https://github.com/microsoft/vscode-python/issues/9829 won't be fixed.

from vimspector.

puremourning avatar puremourning commented on May 18, 2024

There is however a workaround, you can use ptvsd directly instead of vscode-python. It requires different launch configuration, but it does work and doesn't rely on nodejs.

You'll have to work out the adapter configuration for that yourself, but i think this is where the vscode-python starts up ptvsd

from vimspector.

BlueDrink9 avatar BlueDrink9 commented on May 18, 2024

Thanks, I'll take a look at this later

from vimspector.

BlueDrink9 avatar BlueDrink9 commented on May 18, 2024

I might take a look at configuring it myself, but I didn't understand much of what was being said in the ptvsd thread, so it'll be a dedicated project in itself some other time.

Is there much chance you will end up switching it yourself once the standalone version is released?

from vimspector.

BlueDrink9 avatar BlueDrink9 commented on May 18, 2024

Thank you!

from vimspector.

BlueDrink9 avatar BlueDrink9 commented on May 18, 2024

I understand that neovim isn't really supported, but this particular adapter worked fine on vim but not neovim. Are you willing to offer any suggestions?

E+00000.022: Error parsing 'DEBUGPY_LAUNCHER_POR
T':

             Traceback (most recent call last):
               File "/home/user/.local/lib/py
thon3.8/site-packages/debugpy/launcher/__main__.
py", line 36, in option
                 return type(os.environ.pop(name
, *args))
               File "/usr/lib/python3.8/_collect
ions_abc.py", line 795, in pop
                 value = self[key]
               File "/usr/lib/python3.8/os.py",
line 673, in __getitem__
                 raise KeyError(key) from None
             KeyError: 'DEBUGPY_LAUNCHER_PORT'

             Stack where logged:
               File "/usr/lib/python3.8/runpy.py
", line 193, in _run_module_as_main
                 return _run_code(code, main_glo
bals, None,
               File "/usr/lib/python3.8/runpy.py
", line 86, in _run_code
                 exec(code, run_globals)
               File "/home/user/.local/lib/py
thon3.8/site-packages/debugpy/launcher/__main__.
py", line 80, in <module>
                 main()
               File "/home/user/.local/lib/py
thon3.8/site-packages/debugpy/launcher/__main__.
py", line 40, in main
                 launcher_port = option("DEBUGPY
_LAUNCHER_PORT", int)
               File "/home/user/.local/lib/py
thon3.8/site-packages/debugpy/launcher/__main__.
py", line 38, in option
                 raise log.exception("Error pars
ing {0!r}:", name)


Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 193,
in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 86, i
n _run_code
    exec(code, run_globals)
  File "/home/user/.local/lib/python3.8/site-
packages/debugpy/launcher/__main__.py", line 80,
 in <module>
    main()
  File "/home/user/.local/lib/python3.8/site-
packages/debugpy/launcher/__main__.py", line 40,
 in main
    launcher_port = option("DEBUGPY_LAUNCHER_POR
T", int)
  File "/home/user/.local/lib/python3.8/site-
packages/debugpy/launcher/__main__.py", line 38,
 in option
    raise log.exception("Error parsing {0!r}:",
name)
  File "/home/user/.local/lib/python3.8/site-
packages/debugpy/launcher/__main__.py", line 36,
 in option
    return type(os.environ.pop(name, *args))
  File "/usr/lib/python3.8/_collections_abc.py",
 line 795, in pop
    value = self[key]
  File "/usr/lib/python3.8/os.py", line 673, in
__getitem__
    raise KeyError(key) from None
KeyError: 'DEBUGPY_LAUNCHER_PORT'

[Process exited 1]

from vimspector.

puremourning avatar puremourning commented on May 18, 2024

Please see the note in the README.

from vimspector.

BlueDrink9 avatar BlueDrink9 commented on May 18, 2024

Way of the future

from vimspector.

juanMarinero avatar juanMarinero commented on May 18, 2024

TL;DR TLDR (Vim only, no NeoVim)

  • Vim >= 8.2 && Node >= 11
$ [[ $(vim --version 2>&1) =~ "Vi IMproved 8."[2-9] ]] || echo "update VIM"
$ [[ $(node --version 2>&1) =~ v1[1-9] ]] || echo "update Node OR follow no more steps of this github-comment"
  • Install Plug, see docu
    E.g. if junegunn/vim-plug: add Plug 'puremourning/vimspector' to ~/.vimrc. Run :PlugInstall. Run :source ~/.vimrc

  • do NOT run :VimspectorInstall debugpy

  • debug with venv-debugpy
    Create /path/to/vimspector/gadgets/<os>/.gadgets.d/debugpy.json
    E.g. if vim-plugger junegunn/vim-plug && OS GNU-Linux:

$ dir01="$HOME/.vim/plugged/vimspector/gadgets/linux/.gadgets.d" 
$ mkdir -p $dir01  
$ vim $dir01/debugpy.json

Paste and save:

{
  "adapters": {
    "debugpy": {
      "command": [
        "python",
        "-m",
        "debugpy.adapter"
      ],
      "name": "debugpy",
      "configuration": {
        "python": "python"
      }
    }
  }
}
  • $ [activate venv] && pip3 install debugpy --> !!! in every new venv !!!

  • $ vim [projectDirectory]/.vimspector.json --> !!! in every new project !!!
    Paste and save:

{
  "configurations": {
    "univisal: Launch": {
      "adapter": "debugpy",
      "configuration": {
        "name": "<name>: Launch",
        "type": "python",
        "request": "launch",
        "cwd": "${workspaceRoot}",
        "stopOnEntry": true,
        "console": "externalTerminal",
        "debugOptions": [],
        "program": "${file}"
      }
    }
  }
}
  • $ vim [py file] and activate venv (where you pip-installed debugpy)
    E.g. jmcantrell/vim-virtualenv --> :VirtualEnvActivate <tab>

  • launch the awesome Vimspector --> :call vimspector#Launch()

from vimspector.

puremourning avatar puremourning commented on May 18, 2024

Why? Or just use vimspector to install debugpy. What is the purpose of all that effort?

from vimspector.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.