1

I'm gonna be honest, I have no clue what I'm looking at here.

Out of nowhere my Debug configuration in this VSCode project, a Discord bot, has been spitting out errors when I begin debugging. It doesn't do this when running the program normally, and debugging seems to be okay in other projects.

About 50% of the time, it'll end up connecting to Discord despite the errors and debugging works normally, but other times the program will hang and refuse to connect to Discord.

Here is the error text, and I apologize for dumping so much code but I don't know if any of this is significant:

'c:\Users\Lucas\.vscode\extensions\ms-python.python-2021.5.829140558\pythonFiles\lib\python\debugpy\launcher' '51717' '--' 'bot/bot.py' 
pydev debugger: critical: unable to get real case for file. Details:
filename: bot
drive:
parts: ['bot']
(please create a ticket in the tracker to address this).
Traceback (most recent call last):
  File "c:\Users\Lucas\.vscode\extensions\ms-python.python-2021.5.829140558\pythonFiles\lib\python\debugpy\_vendored\pydevd\pydevd_file_utils.py", line 221, in _get_path_with_real_case
    return _resolve_listing(drive, iter(parts))
  File "c:\Users\Lucas\.vscode\extensions\ms-python.python-2021.5.829140558\pythonFiles\lib\python\debugpy\_vendored\pydevd\pydevd_file_utils.py", line 184, in _resolve_listing
    dir_contents = cache[resolved_lower] = os.listdir(resolved)
FileNotFoundError: [WinError 3] The system cannot find the path specified: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\Lucas\.vscode\extensions\ms-python.python-2021.5.829140558\pythonFiles\lib\python\debugpy\_vendored\pydevd\pydevd_file_utils.py", line 226, in _get_path_with_real_case
    return _resolve_listing(drive, iter(parts))
  File "c:\Users\Lucas\.vscode\extensions\ms-python.python-2021.5.829140558\pythonFiles\lib\python\debugpy\_vendored\pydevd\pydevd_file_utils.py", line 184, in _resolve_listing
    dir_contents = cache[resolved_lower] = os.listdir(resolved)
FileNotFoundError: [WinError 3] The system cannot find the path specified: ''
pydev debugger: critical: unable to get real case for file. Details:
filename: bot
drive:
parts: ['bot']
(please create a ticket in the tracker to address this).
Traceback (most recent call last):
  File "c:\Users\Lucas\.vscode\extensions\ms-python.python-2021.5.829140558\pythonFiles\lib\python\debugpy\_vendored\pydevd\pydevd_file_utils.py", line 221, in _get_path_with_real_case
    return _resolve_listing(drive, iter(parts))
  File "c:\Users\Lucas\.vscode\extensions\ms-python.python-2021.5.829140558\pythonFiles\lib\python\debugpy\_vendored\pydevd\pydevd_file_utils.py", line 184, in _resolve_listing
    dir_contents = cache[resolved_lower] = os.listdir(resolved)
FileNotFoundError: [WinError 3] The system cannot find the path specified: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\Lucas\.vscode\extensions\ms-python.python-2021.5.829140558\pythonFiles\lib\python\debugpy\_vendored\pydevd\pydevd_file_utils.py", line 226, in _get_path_with_real_case
    return _resolve_listing(drive, iter(parts))
  File "c:\Users\Lucas\.vscode\extensions\ms-python.python-2021.5.829140558\pythonFiles\lib\python\debugpy\_vendored\pydevd\pydevd_file_utils.py", line 184, in _resolve_listing
    dir_contents = cache[resolved_lower] = os.listdir(resolved)
FileNotFoundError: [WinError 3] The system cannot find the path specified: ''

I've posted a ticket on the tracker mentioned in the error but I honestly have no clue what PyDev is or if there's a way to even just reinstall it and fix the issue.

Is there some kind of workaround? I don't really know what I'm asking purely because this is so unfamiliar to me, but this is just one of those errors that seems to happen spontaneously with no real reason at all.

lucs100
  • 13
  • 1
  • 3
  • No promises, but try this (a similar thing happened to me and I was able to solve it with the following). Are you using a config for your Python debug? Under `./vscode/launch.json` you will have your existing debug configurations for the workspace. If not, set one up. Until a few days ago I had no issues using `./main.py` for my `program` (it seems you used `bot`) but after an update I got an error. Try changing it to `"program": "${workspaceFolder}\\bot.py"` using ${workspaceFolder}\\ and the correct file name and location and see how you go. If this doesn't help, pls paste your `launch.json` – Woodsy May 16 '21 at 23:03
  • @Woodsy I have no clue how but that fixed the issue. Thank you so much. – lucs100 May 17 '21 at 22:05
  • Glad to hear it! If you could accept my answer below that would be great :) – Woodsy May 18 '21 at 23:25

2 Answers2

6

Answer:

Change "program": "bot" to "program": "${workspaceFolder}\\bot.py" in ./.vscode/launch.json.

For most people the file name will not be bot, but main or script or whatever you have called the file of your Python Script. So you would use "${workspaceFolder}\\main.py" etc.

Background:

In a recent update of the pydev debugger I assume they have updated how file locations are parsed.

The file name (VS Code calls it program) you have used is bot, and this syntax no longer works../bot which also used to work will no longer work but will throw a slightly different error. I am not sure if this change is a bug or an intended change.

Your Python debug configuration for your workspace in VS Code is found under {workspaceFolder}/.vscode/launch.json (if you don't already have a launch.json, create one).

You must change "program": "bot" to "program": "${workspaceFolder}\\bot.py" using {workspaceFolder}\\ and the correct file name and location.

This assumes you are launching your workspace from its root directory. You can tell this by the starting directory when you open the integrated terminal.

Woodsy
  • 160
  • 10
0

Here's the reason for such error and a better way to fix it

The error occurs because the python debugger executes files in the terminal from the current open folder (by default)
But you can change this behavior, to use execute in the file's directory:

  • Go to vscode settings (or use the shortcut key: ctrl+comma )
  • then search for this @ext:ms-python.python execute in the settings
  • you would see the settings "Execute in File Dir"
  • then check the box, to execute code in file's directory instead of the current open folder
  • go back to your code and re-run (i.e clicking the debugger run button)

This eliminates the FileNotFoundError when you know your file is sitting in the right place, and you are pointing in the right direction.

John Johnson
  • 543
  • 4
  • 9