Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot debug poetry error: TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType #987

Closed
John15321 opened this issue Jul 13, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@John15321
Copy link

John15321 commented Jul 13, 2022

Issue Type: Bug

Does this issue occur when all extensions are disabled?: Yes/No

  • VS Code Version: Version: 1.69.1
  • OS Version: macOS 12.4 21F79 arm64

Steps to Reproduce:

  1. Install poetry https://python-poetry.org/docs/
  2. Clone the poetry repository
  3. Create a poetry shell by running poetry shell this will create a poetry managed venv (the same issue happens with a normal venv)
  4. Install poetry locally poetry install
  5. Create a debug configuration like this:
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "poetry help",
            "type": "python",
            "request": "launch",
            "module": "poetry",
            "args": [
                "-vvv",
                "--help"
            ],
        },
}
  1. Run the configuration
  2. This is the error Im getting (I also tried it in a debian docker container):
$  cd /Users/john/Documents/Programming/poetry ; /usr/bin/env /Users/john/Library/Caches/pypoetry/virtualenvs/poetry-WR0MsEPb-py3.9/bin/python /Users/john/.vscode/extensions/ms-python.python-2022.10.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher 56594 -- -m poetry -vvv --help
Traceback (most recent call last):
  File "/Users/john/.vscode/extensions/ms-python.python-2022.10.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 252, in _on_run
    self.process_net_command_json(self.py_db, json_contents)
  File "/Users/john/.vscode/extensions/ms-python.python-2022.10.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py", line 193, in process_net_command_json
    cmd = on_request(py_db, request)
  File "/Users/john/.vscode/extensions/ms-python.python-2022.10.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py", line 501, in on_launch_request
    return self._handle_launch_or_attach_request(py_db, request, start_reason='launch')
  File "/Users/john/.vscode/extensions/ms-python.python-2022.10.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py", line 493, in _handle_launch_or_attach_request
    self._set_debug_options(py_db, request.arguments.kwargs, start_reason=start_reason)
  File "/Users/john/.vscode/extensions/ms-python.python-2022.10.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py", line 443, in _set_debug_options
    if os.path.isdir(f):
  File "/Users/john/.pyenv/versions/3.9.11/lib/python3.9/genericpath.py", line 42, in isdir
    st = os.stat(s)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType 

For some reason Pycharm runs an equivalent configuration without a problem:

pyzcarm

Extension version: 2022.10.0
VS Code version: Code 1.69.1 (b06ae3b2d2dbfe28bca3134cc6be65935cdfea6a, 2022-07-12T08:22:10.822Z)
OS version: Darwin arm64 21.5.0
Restricted Mode: No

System Info
Item Value
CPUs Apple M1 Max (10 x 24)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 4, 3, 3
Memory (System) 32.00GB (0.09GB free)
Process Argv --crash-reporter-id 489ac4b7-c1cf-4078-8c18-4b5a4d3d1da5
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vsdfh931cf:30280410
vshan820:30294714
vstes263:30335439
vscorecescf:30445987
pythondataviewer:30285071
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411cf:30525689
vsaa593cf:30376535
vsc1dst:30438360
pythonvs932:30410667
wslgetstarted:30449410
vscscmwlcmt:30465135
cppdebug:30492333
vsclangdc:30486549

@karrtikr karrtikr transferred this issue from microsoft/vscode-python Jul 14, 2022
fabioz added a commit to fabioz/debugpy that referenced this issue Jul 14, 2022
@fabioz
Copy link
Collaborator

fabioz commented Jul 14, 2022

@John15321 thanks for the bug report.

To have it working locally until a new release is done, please apply the fix from fabioz@46608b1 to your local version...

@judej judej added the bug Something isn't working label Jul 14, 2022
@fabioz fabioz closed this as completed in db43846 Jul 14, 2022
@John15321
Copy link
Author

@John15321 thanks for the bug report.

To have it working locally until a new release is done, please apply the fix from fabioz@46608b1 to your local version...

Sorry but could you tell me how to apply this fix locally?

@fabioz
Copy link
Collaborator

fabioz commented Jul 18, 2022

@John15321 thanks for the bug report.
To have it working locally until a new release is done, please apply the fix from fabioz@46608b1 to your local version...

Sorry but could you tell me how to apply this fix locally?

  1. Open the file at your computer:

/Users/john/.vscode/extensions/ms-python.python-2022.10.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py

  1. Change lines 443 -> 446 to be:
               if f:  # argv[0] could be None (https://github.com/microsoft/debugpy/issues/987)
                    if os.path.isdir(f):
                        watch_dirs.append(f)
                    else:
                        watch_dirs.append(os.path.dirname(f))

@Kenny2github
Copy link

Saw this issue today, except on Windows the underlying call is to _isdir instead of stat:

Traceback (most recent call last):
  File "%USERPROFILE%\.vscode\extensions\ms-python.python-2022.10.1\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py", line 252, in _on_run
    self.process_net_command_json(self.py_db, json_contents)
  File "%USERPROFILE%\.vscode\extensions\ms-python.python-2022.10.1\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_process_net_command_json.py", line 193, in process_net_command_json
    cmd = on_request(py_db, request)
  File "%USERPROFILE%\.vscode\extensions\ms-python.python-2022.10.1\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_process_net_command_json.py", line 501, in on_launch_request     
    return self._handle_launch_or_attach_request(py_db, request, start_reason='launch')
  File "%USERPROFILE%\.vscode\extensions\ms-python.python-2022.10.1\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_process_net_command_json.py", line 493, in _handle_launch_or_attach_request
    self._set_debug_options(py_db, request.arguments.kwargs, start_reason=start_reason)
  File "%USERPROFILE%\.vscode\extensions\ms-python.python-2022.10.1\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_process_net_command_json.py", line 443, in _set_debug_options    
    if os.path.isdir(f):
TypeError: _isdir: path should be string, bytes or os.PathLike, not NoneType

Thanks @fabioz for the patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants