question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

VSCode remote debug not working on MacOS

See original GitHub issue

Environment data

VS Code version: 1.20.1 (1.20.1) - MacOS Python Extension version: 2018.1 (01 Feb 2018) Python Version: 3.6.4 on MacOS, 3.5.5 on Armbian (Banana PI M1+) OS and version: MacOS 10.13.3, Armbian 4.14.18-sunxi Mainline kernel ptvsd: 3.0.0 on both MacOS and Server (even tried with the newest one, no change)

Actual behavior

When I launch script with ptsvd on remote server and I try to connect to it from VSCode, I get: Debug adapter process has terminated unexpectedly For internal VSCode log, see attached file vscode - remote debug.log

Expected behavior

Connect to server and start debugging on remote server

Steps to reproduce:

Attach configuration:

    {
      "name": "LowBattery: Remote",
      "type": "python",
      "request": "attach",
      "localRoot": "${workspaceFolder}",
      "remoteRoot": "/home/djmanas/python",
      "port": 3333,
      "secret": "my_secret",
      "host": "192.168.1.101"
    },

Code server.py:

#!/usr/bin/env python3
""" Simple script that will notify user when modules are under certain battery percent """
import ptvsd

ptvsd.enable_attach("my_secret", address=('192.168.1.101', 3333))
ptvsd.wait_for_attach()

print('test‘)

In VSCode, after upload, comment out debug lines.

On server through SSH launch python3 server.py

It waits for attach netstat -lnp

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 192.168.1.101:3333      0.0.0.0:*               LISTEN      30357/python3

Launch the LowBattery: Remote debug configuration and you will get the error.

Does the same thing when I redirect the port through ssh -L 3333:127.0.0.1:3333 and change every IP to localhost.

Logs

Output from Python output panel

##########Linting Output - pep8##########
/usr/local/lib/python3.6/site-packages/pep8.py:2124: UserWarning: 

pep8 has been renamed to pycodestyle (GitHub issue #466)
Use of the pep8 tool will be removed in a future release.
Please install and use `pycodestyle` instead.

$ pip install pycodestyle
$ pycodestyle ...

  '\n\n'
##########Linting Output - pylint##########
No config file found, using default configuration
************* Module netatmoLowBatteryWarning
5,0,warning,W0611:Unused import ptvsd

------------------------------------------------------------------
Your code has been rated at 9.52/10 (previous run: 9.52/10, +0.00)

##########Linting Output - flake8##########
Usage: flake8 [options] file file ...

flake8: error: --disable-noqa option does not take a value

Output from Console window (Help->Developer Tools menu) Please see attached file

Output from Extensions host

[2018-02-18 15:51:50.877] [exthost1] [info] extension host started
[2018-02-18 15:51:50.909] [exthost1] [info] ExtensionService#_doActivateExtension vscode.emmet {"startup":true,"activationEvent":"*"}
[2018-02-18 15:51:50.909] [exthost1] [info] ExtensionService#loadCommonJSModule /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/emmet/out/extension
[2018-02-18 15:51:51.162] [exthost1] [info] ExtensionService#_doActivateExtension vscode.git {"startup":true,"activationEvent":"*"}
[2018-02-18 15:51:51.162] [exthost1] [info] ExtensionService#loadCommonJSModule /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/git/out/main
[2018-02-18 15:51:51.477] [exthost1] [info] ExtensionService#_doActivateExtension vscode.merge-conflict {"startup":true,"activationEvent":"*"}
[2018-02-18 15:51:51.477] [exthost1] [info] ExtensionService#loadCommonJSModule /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/merge-conflict/out/extension
[2018-02-18 15:51:51.554] [exthost1] [info] ExtensionService#_doActivateExtension ms-vscode.cpptools {"startup":true,"activationEvent":"*"}
[2018-02-18 15:51:51.554] [exthost1] [info] ExtensionService#loadCommonJSModule /Users/djmanas/.vscode/extensions/ms-vscode.cpptools-0.15.0/out/src/main
[2018-02-18 15:51:52.517] [exthost1] [info] ExtensionService#_doActivateExtension webfreak.debug {"startup":true,"activationEvent":"*"}
[2018-02-18 15:51:52.517] [exthost1] [info] ExtensionService#loadCommonJSModule /Users/djmanas/.vscode/extensions/webfreak.debug-0.21.2/out/src/frontend/extension
[2018-02-18 15:51:52.523] [exthost1] [info] ExtensionService#_doActivateExtension robertohuertasm.vscode-icons {"startup":true,"activationEvent":"*"}
[2018-02-18 15:51:52.523] [exthost1] [info] ExtensionService#loadCommonJSModule /Users/djmanas/.vscode/extensions/robertohuertasm.vscode-icons-7.20.0/out/src/
[2018-02-18 15:51:52.770] [exthost1] [info] ExtensionService#_doActivateExtension vscode.python {"startup":false,"activationEvent":"onLanguage:python"}
[2018-02-18 15:51:52.770] [exthost1] [info] ExtensionService#loadCommonJSModule /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/python/out/pythonMain
[2018-02-18 15:51:52.774] [exthost1] [info] ExtensionService#_doActivateExtension ms-python.python {"startup":false,"activationEvent":"onLanguage:python"}
[2018-02-18 15:51:52.774] [exthost1] [info] ExtensionService#loadCommonJSModule /Users/djmanas/.vscode/extensions/ms-python.python-2018.1.0/out/client/extension
[2018-02-18 15:51:54.984] [exthost1] [info] eager extensions activated
[2018-02-18 15:51:56.150] [exthost1] [info] ExtensionService#_doActivateExtension platformio.platformio-ide {"startup":true,"activationEvent":"*"}
[2018-02-18 15:51:56.150] [exthost1] [info] ExtensionService#loadCommonJSModule /Users/djmanas/.vscode/extensions/platformio.platformio-ide-0.12.1/lib/main
[2018-02-18 15:53:02.708] [exthost1] [info] extension host started
[2018-02-18 15:53:02.734] [exthost1] [info] ExtensionService#_doActivateExtension vscode.emmet {"startup":true,"activationEvent":"*"}
[2018-02-18 15:53:02.734] [exthost1] [info] ExtensionService#loadCommonJSModule /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/emmet/out/extension
[2018-02-18 15:53:02.804] [exthost1] [info] ExtensionService#_doActivateExtension vscode.git {"startup":true,"activationEvent":"*"}
[2018-02-18 15:53:02.804] [exthost1] [info] ExtensionService#loadCommonJSModule /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/git/out/main
[2018-02-18 15:53:02.895] [exthost1] [info] ExtensionService#_doActivateExtension vscode.merge-conflict {"startup":true,"activationEvent":"*"}
[2018-02-18 15:53:02.895] [exthost1] [info] ExtensionService#loadCommonJSModule /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/merge-conflict/out/extension
[2018-02-18 15:53:02.912] [exthost1] [info] ExtensionService#_doActivateExtension ms-vscode.cpptools {"startup":true,"activationEvent":"*"}
[2018-02-18 15:53:02.912] [exthost1] [info] ExtensionService#loadCommonJSModule /Users/djmanas/.vscode/extensions/ms-vscode.cpptools-0.15.0/out/src/main
[2018-02-18 15:53:03.144] [exthost1] [info] ExtensionService#_doActivateExtension webfreak.debug {"startup":true,"activationEvent":"*"}
[2018-02-18 15:53:03.144] [exthost1] [info] ExtensionService#loadCommonJSModule /Users/djmanas/.vscode/extensions/webfreak.debug-0.21.2/out/src/frontend/extension
[2018-02-18 15:53:03.146] [exthost1] [info] ExtensionService#_doActivateExtension robertohuertasm.vscode-icons {"startup":true,"activationEvent":"*"}
[2018-02-18 15:53:03.146] [exthost1] [info] ExtensionService#loadCommonJSModule /Users/djmanas/.vscode/extensions/robertohuertasm.vscode-icons-7.20.0/out/src/
[2018-02-18 15:53:03.866] [exthost1] [info] eager extensions activated
[2018-02-18 15:53:04.156] [exthost1] [info] ExtensionService#_doActivateExtension platformio.platformio-ide {"startup":true,"activationEvent":"*"}
[2018-02-18 15:53:04.156] [exthost1] [info] ExtensionService#loadCommonJSModule /Users/djmanas/.vscode/extensions/platformio.platformio-ide-0.12.1/lib/main
[2018-02-18 19:02:36.522] [exthost1] [info] extension host started
[2018-02-18 19:02:36.556] [exthost1] [info] ExtensionService#_doActivateExtension vscode.emmet {"startup":true,"activationEvent":"*"}
[2018-02-18 19:02:36.556] [exthost1] [info] ExtensionService#loadCommonJSModule /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/emmet/out/extension
[2018-02-18 19:02:36.903] [exthost1] [info] ExtensionService#_doActivateExtension vscode.git {"startup":true,"activationEvent":"*"}
[2018-02-18 19:02:36.903] [exthost1] [info] ExtensionService#loadCommonJSModule /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/git/out/main
[2018-02-18 19:02:37.311] [exthost1] [info] ExtensionService#_doActivateExtension vscode.merge-conflict {"startup":true,"activationEvent":"*"}
[2018-02-18 19:02:37.311] [exthost1] [info] ExtensionService#loadCommonJSModule /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/merge-conflict/out/extension
[2018-02-18 19:02:37.412] [exthost1] [info] ExtensionService#_doActivateExtension ms-vscode.cpptools {"startup":true,"activationEvent":"*"}
[2018-02-18 19:02:37.412] [exthost1] [info] ExtensionService#loadCommonJSModule /Users/djmanas/.vscode/extensions/ms-vscode.cpptools-0.15.0/out/src/main
[2018-02-18 19:02:38.659] [exthost1] [info] ExtensionService#_doActivateExtension webfreak.debug {"startup":true,"activationEvent":"*"}
[2018-02-18 19:02:38.659] [exthost1] [info] ExtensionService#loadCommonJSModule /Users/djmanas/.vscode/extensions/webfreak.debug-0.21.2/out/src/frontend/extension
[2018-02-18 19:02:38.670] [exthost1] [info] ExtensionService#_doActivateExtension robertohuertasm.vscode-icons {"startup":true,"activationEvent":"*"}
[2018-02-18 19:02:38.670] [exthost1] [info] ExtensionService#loadCommonJSModule /Users/djmanas/.vscode/extensions/robertohuertasm.vscode-icons-7.20.0/out/src/
[2018-02-18 19:02:39.121] [exthost1] [info] ExtensionService#_doActivateExtension vscode.python {"startup":false,"activationEvent":"onLanguage:python"}
[2018-02-18 19:02:39.121] [exthost1] [info] ExtensionService#loadCommonJSModule /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/python/out/pythonMain
[2018-02-18 19:02:39.125] [exthost1] [info] ExtensionService#_doActivateExtension ms-python.python {"startup":false,"activationEvent":"onLanguage:python"}
[2018-02-18 19:02:39.125] [exthost1] [info] ExtensionService#loadCommonJSModule /Users/djmanas/.vscode/extensions/ms-python.python-2018.1.0/out/client/extension
[2018-02-18 19:02:43.138] [exthost1] [info] eager extensions activated
[2018-02-18 19:02:44.400] [exthost1] [info] ExtensionService#_doActivateExtension platformio.platformio-ide {"startup":true,"activationEvent":"*"}
[2018-02-18 19:02:44.400] [exthost1] [info] ExtensionService#loadCommonJSModule /Users/djmanas/.vscode/extensions/platformio.platformio-ide-0.12.1/lib/main

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:48 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
DonJayamannecommented, Feb 18, 2018

And should I use ptvsd 3.0.0 or the newest one?

PTVSD version 3.0.0

I didn’t get the message about it, but it haven’t stopped at the print statement.

You need to wait for 5 seconds (remember, there’s a time.sleep). You could reduce that to 1-2 seconds.

0reactions
DJManascommented, Jun 10, 2018

Yep. For me it is working flawlesslly, thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Debugging in Visual Studio Code
Launch the program to debug ("debug target") manually in a terminal or command prompt and redirect input/output as needed. Make sure to pass...
Read more >
Debugging configurations for Python apps in Visual Studio Code
Remote debugging allows you to step through a program locally within VS Code while it runs on a remote computer. It is not...
Read more >
Remote Development Tips and Tricks - Visual Studio Code
Remote Development Tips and Tricks. This article covers troubleshooting tips and tricks for each of the Visual Studio Code Remote Development extensions.
Read more >
Run and Debug Java in Visual Studio Code
Running and debugging Java. Visual Studio Code allows you to debug Java applications through the Debugger for Java extension. It's a lightweight Java ......
Read more >
Debug Browser Apps using Visual Studio Code
The Visual Studio Code editor includes browser debugging support. ... the command will open a new window of any running browser and not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found