Skip to content

Modules with two leading slashes can't be mapped properly in VS Code debugger #1065

Closed

Description

@OEP

Hi, this is a follow-up to a discussion (microsoft/vscode-python#19835). I reported to debugpy (#1061), it was reproduced there, and they referred me to the main repo (microsoft/vscode#161498). They've asked me to report here.

EDIT: See microsoft/vscode#161498 for resolution.

Behaviour

When a module has two slashes in its path, the path mapping in the debugger does not seem to work.

Expected vs. Actual

In VS Code, the breakpoint is hit, but path-mapping does not work with an error in the editor pane.

The editor could not be opened because the file was not found.

Creating the file tries to mkdir /vscode-path and fails.

In some cases I have also seen this error in the Call Stack pane.

[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")

I was expecting the path mapping to work since two leading slashes is technically an OK path on Linux and macOS.

Steps to reproduce:

Create a file like the following:

$ cat /tmp/vscode-path/vscode_blah.py 
import sys
import pprint
pprint.pprint(sys.path)

import debugpy
debugpy.listen(5678)
print("WAIT")
debugpy.wait_for_client()

print("HEY")

Set a breakpoint on that final print().

Create a standard "remote attach" debug configuration.

{
        "host": "localhost",
        "name": "Remote Attach",
        "port": 5678,
        "request": "attach",
        "type": "python"
}

In the VS Code editor, set a breakpoint on the final print().

Try to import it via a PYTHONPATH with a leading double slash.

$ PYTHONPATH=//tmp/vscode-path python3 -c "import vscode_blah"

Use the Remote Attach configuration to try and debug the process.

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.9.12
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Global
  • Value of the python.languageServer setting: Default
Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)

Experiment 'pythonTensorboardExperiment' is active
Experiment 'PythonPyTorchProfiler' is active
LSP Notebooks experiment is disabled -- Jupyter does not support experiment
> conda info --json
Python interpreter path: /usr/local/bin/python3
> /usr/bin/python ~/.vscode/extensions/ms-python.python-2022.8.1/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2022.8.1/pythonFiles/interpreterInfo.py
> /usr/bin/python3 ~/.vscode/extensions/ms-python.python-2022.8.1/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2022.8.1/pythonFiles/interpreterInfo.py
> /usr/lib/python2.7 ~/.vscode/extensions/ms-python.python-2022.8.1/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2022.8.1/pythonFiles/interpreterInfo.py
> /usr/local/bin/python3 ~/.vscode/extensions/ms-python.python-2022.8.1/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2022.8.1/pythonFiles/interpreterInfo.py
[ERROR 2022-8-22 20:25:55.856]: Error: Command failed: /usr/lib/python2.7 /Users/pkilgo/.vscode/extensions/ms-python.python-2022.8.1/pythonFiles/get_output_via_markers.py /Users/pkilgo/.vscode/extensions/ms-python.python-2022.8.1/pythonFiles/interpreterInfo.py
/bin/sh: /usr/lib/python2.7: is a directory

    at ChildProcess.exithandler (node:child_process:408:12)
    at ChildProcess.emit (node:events:526:28)
    at maybeClose (node:internal/child_process:1092:16)
    at Socket.<anonymous> (node:internal/child_process:451:11)
    at Socket.emit (node:events:526:28)
    at Pipe.<anonymous> (node:net:687:12) {
  killed: false,
  code: 126,
  signal: null,
  cmd: '/usr/lib/python2.7 /Users/pkilgo/.vscode/extensions/ms-python.python-2022.8.1/pythonFiles/get_output_via_markers.py /Users/pkilgo/.vscode/extensions/ms-python.python-2022.8.1/pythonFiles/interpreterInfo.py'
}
Starting Pylance language server.
Connecting to DAP Server at:  localhost:5678

User Settings


languageServer: "Pylance"

Activity

  1. fabioz commented on Sep 24, 2022

    @fabioz
    Collaborator

    I see you're doing the roundtrip there ;)

    I've just commented on microsoft/vscode#161498 (comment) why I think the issue is on VSCode itself.

  2. karthiknadig commented on Sep 24, 2022

    @karthiknadig
    Member

    This should be then re-open on VS Code itself. Python extension is not involved here. This is handled by DAP client.

  3. karthiknadig commented on Sep 24, 2022

    @karthiknadig
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions