vscode-jest-runner icon indicating copy to clipboard operation
vscode-jest-runner copied to clipboard

Wrong node path in debugger

Open 4javier opened this issue 2 years ago • 2 comments

When VSCode OSS gets launched from Gnome dock, executing a debugging session from the extension sets wrong execPath in VSCODE_INSPECTOR_OPTIONS. In particular it misses the path set by NVM (Node Version Manager) and takes in account only system one /usr/bin/node. At first I thought it was the dock not launching the IDE in a login shell, but the fact that the problem doesn't arise during normal test runnings but only during debugging, makes me wonder if the error resides somewhere else. I put a log statement inside my test to inspect ENV set during debugging, and they are the correct ones. In particular:

PATH: '/home/javier/.nvm/versions/node/v18.15.0/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/mnt/dati/Android-mess/AIK-Linux-v3.2-ALL/AIK-Linux/bin/x86_64:/mnt/dati/Android-mess/AIK-Linux-v3.2-ALL/AIK-Linux/bin/x86_64'

As you can see, the user specific one pointing to current nvm symlink is listed before system one, so it should be picked by debugger. But in the same logging you can read:

VSCODE_INSPECTOR_OPTIONS: '{"inspectorIpc":"/tmp/node-cdp.51155-1.sock","deferredMode":false,"waitForDebugger":"","execPath":"/usr/bin/node","onlyEntrypoint":false,"autoAttachMode":"always","openerId":"6dce2110cff9942794784425"}',

If I launch VSCode from a terminal, execPath inside inspector options point to the correct user-wide Node path.

Version: 1.76.2
Commit: ee2b180d582a7f601fa6ecfdad8d9fd269ab1884
Date: 2023-03-16T10:00:00.439Z
Electron: 19.1.9
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Linux x64 6.2.6-arch1-1
Sandboxed: No
Jest Runner
v0.4.60

4javier avatar Mar 19 '23 20:03 4javier

So I think what is happening here is the PATH variable of VS code process doesn't have .nvm in it when it is launched from the gnome dock.

The "run" buttons runs node directly in the terminal, which resolves from the PATH of the VS code terminal.

The "debug" button calls vscode.debug.startDebugging, which uses the VS code API to resolve to an absolute path of the node executable.

So "run" and "debug" use different PATH variables here, notably "debug" does not use PATH of the terminal it seems.

the user specific one pointing to current nvm symlink is listed before system one, so it should be picked by debugger.

I'm not sure if we want to do this, but if we did, vscode.debug.startDebugging would need to be aware of the PATH variable of the current active terminal I think? Or at least the way node is resolved by the debugging would need to change, open to suggestions here

domsleee avatar Oct 15 '23 04:10 domsleee