Repository navigation
VSCode remote debug not working on MacOS #819
Description
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
Activity
DonJayamanne commentedon Feb 18, 2018
Please try the following:
The problem is, the debugger attaches, but when it hits the print statement it continues and the program ends.
Hence the need for the delay using
time.sleepDJManas commentedon Feb 18, 2018
Ok, did that.
I didn’t get the message about it, but it haven’t stopped at the print statement.
Attaching picture from VSCode and the log.

1518981725042.log
DJManas commentedon Feb 18, 2018
And should I use ptvsd 3.0.0 or the newest one?
DonJayamanne commentedon Feb 18, 2018
PTVSD version 3.0.0
You need to wait for 5 seconds (remember, there's a
time.sleep).You could reduce that to 1-2 seconds.
DJManas commentedon Feb 18, 2018
When I hit the green arrow to „Restart“ the debug I get the one previous error.
1518982058645.log
The Armbian ptvsd
MacOS ptvsd
I had waited 10 seconds before restarting.
DJManas commentedon Feb 18, 2018
Sorry MacOS version is 3.2.1. Reinstalling back 3.0.0 and tryiing again
DJManas commentedon Feb 18, 2018
Nope, still the same.
DonJayamanne commentedon Feb 18, 2018
Please ensure you have PTVSD 3.0.0, other versions are not supported (you had some other version installed)
Please try connecting to the remote environment using a tool such as
ncor the like from the command line, as follows:nc 192.168.1.101 3333Let me know what you get in the console window?
If you cannot connect in the terminal, then debugger will not work.
Please change the code as follows:
waiting to attachis printed in the console window on the remote environmentdebug consoleas well as the terminal on the remote environment (i.e. is the outputattacheddisplayed` on the remote computer?)DJManas commentedon Feb 18, 2018
Ok.
MacOS pip3 list, stripped to ptvsd
Armbian pip3 list, stripped to ptvsd only
Contents of netatmoLowBatteryWarning.py
Contents of same file in VSCode
Launched the file on armbian python3 netatmoLowBatteryWarning.py
Checking of port nc -z 192.168.1.101 3333
Opened VSCode and launched the code in debug the message fired up right away

Output on the remote server
nc - z 192.168.1.101 3333
Log from VSCode
[1518990271994.log](https://github.com/Microsoft/vscode-python/files/1735142/1518990271994.
DonJayamanne commentedon Feb 18, 2018
Please could you try running it locally and attaching to it. Lets remove the remote aspect from this and try everything locally.
DJManas commentedon Feb 18, 2018
Ok.
Changed configuration to
Changed code to:
Launched the code locally
nc -z localhost 3333
VSCode commented the 2 lines
Yep it connects

Result on console
So I guess what is the resume?
DonJayamanne commentedon Feb 18, 2018
What do you mean by this?
35 remaining items
nikhilweee commentedon May 10, 2018
Petr Šourek (@DJManas) Don Jayamanne (@DonJayamanne) did you figure out the problem? Is there a solution yet?
brettcannon commentedon May 10, 2018
Nikhil Verma (@nikhilweee) no and no, unfortunately.
DonJayamanne commentedon May 29, 2018
Petr Šourek (@DJManas)
Please could you try this once again with our latest
experimentaldebugger (an improved debugger):pip install ptvsd --pre(install this on your remote environment)launch.jsonfrom"type":"python"to"type":"pythonExperimental"ptvsd.enable_attach(address=('192.168.1.101', 3333))instead ofptvsd.enable_attach("my_secret", address=('192.168.1.101', 3333))(themy_secretargument should be dropped)DJManas commentedon May 30, 2018
Hello,
2018.4.0
Result:
Thanks,
Regards,
Petr Sourek
DonJayamanne commentedon Jun 4, 2018
This issue has been resolved in PTVSD.
So, we can finally confirm this issue works with the new
experimentaldebugger.DJManas commentedon Jun 10, 2018
Yep. For me it is working flawlesslly, thanks