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

remote debugging - remote server is different OS from local server #948

Closed
weinand opened this issue Mar 5, 2018 · 6 comments
Closed

remote debugging - remote server is different OS from local server #948

weinand opened this issue Mar 5, 2018 · 6 comments

Comments

@weinand
Copy link

weinand commented Mar 5, 2018

From @Loreton on March 2, 2018 15:47

  • VSCode Version: 1.17.2
  • OS Version: Windows 7

Steps to Reproduce:

  1. prepare code on linux using netiface module
  2. run debug from windows to remote linux
    When the local module (windows), in my case "netifaces", has different characteristics from remote module (linux) we get error reading the network interface caracteristics. Why? It should run remote code and not local code.
    Regards

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

Copied from original issue: microsoft/vscode#44932

@weinand
Copy link
Author

weinand commented Mar 5, 2018

From @vscodebot[bot] on March 2, 2018 15:47

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@weinand
Copy link
Author

weinand commented Mar 5, 2018

From @isidorn on March 2, 2018 15:56

Sounds like a potential duplicate of the wsl issues, forwarding to @weinand

@weinand
Copy link
Author

weinand commented Mar 5, 2018

@Loreton How does your launch config look like?

@weinand
Copy link
Author

weinand commented Mar 5, 2018

From @Loreton on March 5, 2018 11:4

my main.py code

# ####################################
# #### R E M O T E  - Linux OS #############
# ####################################

# ******** D E B U G *********************************
import ptvsd
ptvsd.enable_attach("my_secret", address=('localhost', 3000))
ptvsd.wait_for_attach() # only in the remote node
# ******** D E B U G *********************************


import sys; sys.dont_write_bytecode = True
import  Source as Prj

myLibName = ['LnPyLib', 'DDNS_v2018-02-27.zip'] 
LnLib     = Prj.SPE.LibPath(myLibName, fDEBUG=False)



# ####################################
# #### L O C A L    Windows OS ############
# ####################################

# ******** D E B U G *********************************
import ptvsd
ptvsd.enable_attach("my_secret", address=('localhost', 3000))
# ptvsd.wait_for_attach() # only in the remote node
# ******** D E B U G *********************************


import sys; sys.dont_write_bytecode = True
import  Source as Prj

myLibName = ['LnPyLib', 'DDNS_v2018-02-27.zip']   **_<=== BreakPoint_**
LnLib     = Prj.SPE.LibPath(myLibName, fDEBUG=False)

Problem

When I start the debugger I can STEP just the first two line and the I get an error regarding a missing feature of netifaces module (AF_PACKET).

  File "y:\GIT-REPO\Python3\DDNS\__main__.py", line 79, in <module>
    Prj.Main(gv.args.firstPosParameter)
  File "y:\GIT-REPO\Python3\DDNS\Source\Main\DDNS_Main.py", line 83, in Main
    interfaces     = Ln.getInterfaces(dictType=Ln.Dict)
  File "y:\GIT-REPO\Python3\DDNS\LnPyLib\Net\InterfacesCl.py", line 418, in getInterfaces
    ifc = Interfaces(ifcName)
  File "y:\GIT-REPO\Python3\DDNS\LnPyLib\Net\InterfacesCl.py", line 116, in __init__
    self.arpPing(self._gatewayIpAddress)
  File "y:\GIT-REPO\Python3\DDNS\LnPyLib\Net\InterfacesCl.py", line 319, in arpPing
    macAddressHex   =  bytes.fromhex(self._MAC_address.replace(':',''))
AttributeError: 'NoneType' object has no attribute 'replace'

But this feature is missed just in windows module and not in linux one.
In any case:

  1. it doesn't stop in the breakpoint line.
  2. the TCP connection to remote machine NOT starts

launch extract configuration

   "configurations": [
        {
            "name": "Python",
            "type": "python",
            "request": "launch",
            "stopOnEntry": true,
            "pythonPath": "${config:python.pythonPath}",
            "program": "${file}",
            "cwd": "${workspaceRoot}",
            "env": {},
            "envFile": "${workspaceRoot}/.env",
            "debugOptions": [
                // "WaitOnAbnormalExit",
                // "WaitOnNormalExit",
                "RedirectOutput"
            ],
            "args": [
                "update",
                "--profile",
                "LnPi23"
            ]
        },
    ....
    i have the following tunnel ssh -L 3001:destMaschine:3000 
        {
            "name": "Attach (Remote Debug)",
            "type": "python",
            "request": "attach",
            "localRoot": "${workspaceRoot}",
            "remoteRoot": "/home/pi/GIT-REPO/Python3/DDNS",
            "port": 3001,    
            "secret": "my_secret",
            "host": "localhost"
        }
    ]

Kind Regards

@DonJayamanne
Copy link

DonJayamanne commented Mar 5, 2018

@lorento
Please could you change the remote python file being debugged as follows:

my main.py code

import ptvsd
ptvsd.enable_attach("my_secret", address=('localhost', 3000))
ptvsd.wait_for_attach()


print("attached")
a = input()
print("something entered")    # **_<=== BreakPoint_**
print("End")                  # **_<=== BreakPoint_**
  • Run the above file on the remote linux computer in a terminal window
  • Ensure the above file is also available on the local widows computer
  • Go into your local windows computer
  • Add a break point to the line print("something entered") and the line after as well
  • Select Attach (Remote Debug) and run that.
    Note: None of the Python code gets executed locally on your windows machine.

@DonJayamanne DonJayamanne added bug Issue identified by VS Code Team member as probable bug area-debugging info-needed Issue requires more information from poster labels Mar 5, 2018
@Loreton
Copy link

Loreton commented Mar 6, 2018

Hi Don,
reading your last update, when you said:

"Select Attach (Remote Debug) and run that."

I realized I had omitted something important. I didn't select the configuration type to be used for debugging. I left the default. Selecting the right configuration it works fine and very fast.
I am very sorry to have bothered You for my mistake.
Thanks for Your support and best compliments for this product that I'm starting to discover.
It's OK for me. Problem is solved.
Regards
Loreto

@DonJayamanne DonJayamanne added closed-invalid and removed info-needed Issue requires more information from poster bug Issue identified by VS Code Team member as probable bug labels Mar 6, 2018
brettcannon pushed a commit to brettcannon/vscode-python that referenced this issue Mar 6, 2018
* Add support for multi roots for formatting and linting (microsoft#1281)

* update to use latest api

* config changes for multiroot workspace

* linting support with multi roots

* multi root support for formatters

* determine workspace root path

* revert change

* support multiple configs per workspace folder

* modify formatters to use resource specific settings

* modified to settings are resolved using document uri

* 1228 multi root master (#1)

* fix microsoft#1280 handle env in shebang (microsoft#1290)

* handle shebangs that resolve paths from env

* oops

* make test more specific

* handle promise

* fix microsoft#1282 use PYTHONIOENCODING variable (microsoft#1291)

* fix microsoft#1270 debugger contribution changes (microsoft#1288)

* add onDebug activation

* use debug config provider for non workspace debugging

* forgot to save file before commiting a merge

* ability to opt out of telemetry using vscode settings (microsoft#1297)

* Fix microsoft#1284 debugging parameterized tests (microsoft#1299)

* fix microsoft#1298 remove vscode.startDebug command (microsoft#1300)

* fix microsoft#1298 remove vscode.startDebug command

* fix code review comments

* added period as per code review comments

* microsoft#1288 installer config and tests (microsoft#1302)

* update to use latest api

* config changes for multiroot workspace

* linting support with multi roots

* multi root support for formatters

* determine workspace root path

* revert change

* support multiple configs per workspace folder

* modify formatters to use resource specific settings

* modified installer to pass resource for workspace resolution

* null test in installer

* canges to config settings to support multiroot workspace

* changes to code refactoring to support workspace symbols

* oops

* modified to settings are resolved using document uri

* unit tests for multi root support

* fix unittests for multiroot

* exclude files

* add new line

* config changes for multiroot workspace

* new lines and enabled multi root linter tests

* fix sys variables

* added unit test to resolve ${workspaceRoot} in settings.json

* fixed code review comments

* fixed code review comments

* fix microsoft#1276 Pre-commit hooks to ensure code complies with standards (microsoft#1277)

* sanitize code

* gulp file to check code hygiene

* fix preLaunchTask in launch.json

* added missing packages

* enabled pre-commit using husky

* enabled a few checks for precommit hook

* fix tslint warnings when running tslint via gulp

* exclude webpack building, else tries to pull in tests as well

* improved checks for commits (strict)

* added new lines

* 1228 multi root workspace symbols (microsoft#1307)

* update to use latest api

* config changes for multiroot workspace

* linting support with multi roots

* multi root support for formatters

* determine workspace root path

* revert change

* support multiple configs per workspace folder

* modify formatters to use resource specific settings

* modified installer to pass resource for workspace resolution

* null test in installer

* canges to config settings to support multiroot workspace

* changes to code refactoring to support workspace symbols

* oops

* modified to settings are resolved using document uri

* unit tests for multi root support

* fix unittests for multiroot

* exclude files

* add new line

* config changes for multiroot workspace

* new lines and enabled multi root linter tests

* fix sys variables

* added unit test to resolve ${workspaceRoot} in settings.json

* microsoft#1228 workspace symbols with multiroot support

* fix test

* added some data for workspace symbol tests

* data for unit tests

* fixed to add support for multit roots with unit tests

* account for mutiroot files in sub directory

* disable all but multiroot tests

* fixed tests

* include files for tests

* Fixed travis tests for multi root workspace symbols (microsoft#1306)

* added logging

* more logging

* yay

* fixed

* more fixes

* fix tests

* removed logging

* enable all tests

* uncommented

* Added brackets around print statements (for p3)

* Fixed travis unit tests (microsoft#1308)

* update to use latest api

* config changes for multiroot workspace

* linting support with multi roots

* multi root support for formatters

* determine workspace root path

* revert change

* support multiple configs per workspace folder

* modify formatters to use resource specific settings

* modified installer to pass resource for workspace resolution

* null test in installer

* canges to config settings to support multiroot workspace

* changes to code refactoring to support workspace symbols

* oops

* modified to settings are resolved using document uri

* unit tests for multi root support

* fix unittests for multiroot

* exclude files

* add new line

* config changes for multiroot workspace

* new lines and enabled multi root linter tests

* fix sys variables

* added unit test to resolve ${workspaceRoot} in settings.json

* microsoft#1228 workspace symbols with multiroot support

* fix test

* added some data for workspace symbol tests

* data for unit tests

* fixed to add support for multit roots with unit tests

* account for mutiroot files in sub directory

* disable all but multiroot tests

* fixed tests

* fix tests

* test where failing

* properly determine root workspace

* fix pytest unit test

* delete files

* add awaiter

* use a path that works on multiple os

* fixes

* uncomment

* invert

* debug statements

* use default workspace

* reverted unwanted changes

* oops

* test unittests only

* more logging

* partial fixes to unit tests

* run all tests

* changes not to set paths for shebang tests

* remove comments

* update settings only if necessary

* fix test

* include files for tests

* Fixed travis tests for multi root workspace symbols (microsoft#1306)

* added logging

* more logging

* yay

* fixed

* more fixes

* fix tests

* removed logging

* enable all tests

* uncommented

* Added brackets around print statements (for p3)

* use resource when getting settings

* fix microsoft#1315 unit tests need to wait for extension to activate (microsoft#1316)

* fix microsoft#1314 allow for simultaneous language features (microsoft#1317)

* microsoft#1228 support multi roots in language service (microsoft#1309)

* update to use latest api

* config changes for multiroot workspace

* linting support with multi roots

* multi root support for formatters

* determine workspace root path

* revert change

* support multiple configs per workspace folder

* modify formatters to use resource specific settings

* modified installer to pass resource for workspace resolution

* null test in installer

* canges to config settings to support multiroot workspace

* changes to code refactoring to support workspace symbols

* oops

* modified to settings are resolved using document uri

* unit tests for multi root support

* fix unittests for multiroot

* exclude files

* add new line

* config changes for multiroot workspace

* new lines and enabled multi root linter tests

* fix sys variables

* added unit test to resolve ${workspaceRoot} in settings.json

* microsoft#1228 workspace symbols with multiroot support

* fix test

* added some data for workspace symbol tests

* data for unit tests

* fixed to add support for multit roots with unit tests

* account for mutiroot files in sub directory

* disable all but multiroot tests

* fixed tests

* fix tests

* test where failing

* properly determine root workspace

* fix pytest unit test

* delete files

* add awaiter

* use a path that works on multiple os

* fixes

* uncomment

* invert

* debug statements

* use default workspace

* reverted unwanted changes

* oops

* test unittests only

* more logging

* partial fixes to unit tests

* run all tests

* changes not to set paths for shebang tests

* remove comments

* update settings only if necessary

* fix test

* include files for tests

* Fixed travis tests for multi root workspace symbols (microsoft#1306)

* added logging

* more logging

* yay

* fixed

* more fixes

* fix tests

* removed logging

* enable all tests

* uncommented

* Added brackets around print statements (for p3)

* use resource when getting settings

* support multiroot in language services

* add additional tests for microsoft#1314 (microsoft#1318)

* microsoft#1228 run all tests under multiroot (microsoft#1322)

* modifications to fix tests to run under multi root setup

* log errors

* fix return type

* fix linter messages

* fix linter errors

* changes to ensure code is formatted correctly

* fixed comments

* delete unwanted file

* hide unwanted folders

* fixes to linters to run on multiroot setup

* udpate settings sequentially

* log the output

* show errors in deleting dir

* removed prospector test, to be completed in microsoft#1319

* fixes to tests and sorting provider

* fixed test for interpreter display

* undo commenting of code

* add new line

* fix code review issues

* ensure else is properly formatted

* fix code review comments

* fix microsoft#1304 preserve empty lines (microsoft#1329)

* microsoft#1228 multiroot interpreter display (microsoft#1339)

* modifications to fix tests to run under multi root setup

* log errors

* fix return type

* fix linter messages

* fix linter errors

* changes to ensure code is formatted correctly

* fixed comments

* delete unwanted file

* hide unwanted folders

* fixes to linters to run on multiroot setup

* udpate settings sequentially

* log the output

* show errors in deleting dir

* removed prospector test, to be completed in microsoft#1319

* fixes to tests and sorting provider

* fixed test for interpreter display

* undo commenting of code

* add new line

* support multi root in interpreter display

* fix linter

* changed package version

* disabled multiroot test

* backwards compatible change

* fix nose tests

* revert change

* enable test but disable it

* multi root support in utils.ts

* fixed microsoft#1328

* retries for flaky unit tests

* retry beforeEach

* common retry decorator

* enable telemetry for extension loads

* disable jupyter tests in multiroot tests

* clean up python Path before and after testsclean up python Path before and after tests

* rename test env variable

* dispose cfg settings

* dispose cfg settings

* update comment

* clean up

* rearrange to ensurfe launching ext is first debug option

* bug fix for display name

* resolved code review comment

* Fixed typp

* 1228 multiroot interpreter ui changes (microsoft#1345)

* fixes to unit tests and forgotten multiroot

* globally retry all tests 3 times

* refactor changing interpreters

* added tests

* fixed linter

* removed redundant files

* removed unwanted grep

* remove blank line

* fix 948 remove hardcoding of port number (microsoft#1353)

* fix microsoft#1041 when debugging a test do not cancel it when re-discovering tests (microsoft#1354)

* fix 1041 when debugging a test do not cancel it when re-discovering tests

* create enum for creation of cancellation token

* dispose correct cancellationToken

* bug fix - in unit tests

* bug fix - in unit tests

* microsoft#1228 multiroot unit test runner (microsoft#1357)

* fixes to unit tests and forgotten multiroot

* globally retry all tests 3 times

* refactor changing interpreters

* added tests

* fixed linter

* removed redundant files

* temp changes

* more changes

* lots of refactoring

* adding support for multiroot workspaces

* removed grep

* copy changes for microsoft#948 and microsoft#1353 into multroot

* replicate solution for microsoft#1041 and microsoft#1354

* microsoft#1041 create enum for creation of cancellation token

* multiroot support for unit tests

* remove empty line (linter warning)

* delete pyc before making changes to py file

* delete pyc file in teardown

* merged multiroot master

* pass uri of workspace when displaing prompt for configuration

* pass uri to commands

* fixed typos based on code review

* prefix path with forward slash, as is done in the extension  unit tests

* include version number into display name
@lock lock bot locked as resolved and limited conversation to collaborators Jul 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants