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

nushell doesn't work with debugpy (python debugger) #1853

Open
ishipachev opened this issue Oct 17, 2024 · 7 comments
Open

nushell doesn't work with debugpy (python debugger) #1853

ishipachev opened this issue Oct 17, 2024 · 7 comments
Assignees
Labels
needs repro Issue has not been reproduced yet

Comments

@ishipachev
Copy link

ishipachev commented Oct 17, 2024

Does this issue occur when all extensions are disabled?: Well. I need Python extension to make it run.

The issue description (system details at the bottom):

Seems like even though it says that nushell is supported now in VSCode in August release (here is the announce), it still can't be used as one of Internal Terminals when you try to debug python script. It gets call with a sequence not compatible with nushell syntax like this one.

a) Pixi's environemnt python bad command example:

cmd /C "c:\dev\data_processing\.pixi\envs\default\python.exe c:\Users\360ci\.vscode\extensions\ms-python.debugpy-2024.12.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher 54917 -- c:\dev\data_processing\test.py "

b) Conda's environment python bad command example:

c: && cd c:\dev\sfms && cmd /C "c:\programs\miniconda\envs\data_proc\python.exe c:\Users\360ci\.vscode\extensions\ms-python.debugpy-2024.12.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher 50270 -- c:\dev\sfms\test.py "

Screenshot:
Image

It DOES work when you just try to run the script because comparing with debug sequence it doesn't have nushell incompatible command in this case. Because when you try to just run it correctly forms the line. Here is example of the command which works

Conda's good and compatible command when you just run without debugger:

C:/programs/miniconda/envs/data_proc/python.exe c:/dev/sfms/test.py

@anthonykim1, I saw you latest work on having nushell and julia integrated into VSCode, but I think there is a small chance that I misunderstand how it is expected to work?

The isssue is also discussed here in nushell repo:
nushell/nushell#14022
Here is also one of my comments on this problem with some advices from one of the authors:
nushell/nushell#2775 (comment)

@IanManske point outed here that the problem in these lines where nushell is not supported:
https://github.com/microsoft/vscode/blob/321e1e5b8a0af43a0ee7549713f606936a1ac9ac/src/vs/workbench/contrib/debug/node/terminals.ts#L81

Details

  • VS Code Version: 1.94.2
  • OS Version: Win10: 10.0.19045 Build 19045
  • Plugins: Python plugin, but no nushell plugin (is it needed?)

Steps to Reproduce:

  1. Install nushell in your system.
  2. Go to Settings, to to Terminal > Integrated > Default Profile: Windows, set up "path" to installed nushell
  3. Have a small python program like print("Hello nu in vscode")
  4. Click on the "Run" arrow, selecting "Python Debugger: Debug Python File"
  5. Get error message caused by ill-formed command Error: × Invalid literal complaining (see the above the full command it calls) about "" or "&&" symbols in the string.
@karthiknadig
Copy link
Member

This is actually handled in the run-in-terminal request from DAP, in the VS Code DAP client.

@karthiknadig karthiknadig added the bug Something isn't working label Dec 11, 2024
@ishipachev
Copy link
Author

Hi @karthiknadig,
Does it mean it will be fixed as a part of the work on other component? What is the best way to track it?

@karthiknadig
Copy link
Member

@ishipachev I think this change might needs fixes in debugpy itself, and may be few other components.

@rchiodo The run in terminal command is sent from debugpy , does it receive any shell information?

@karthiknadig karthiknadig removed the bug Something isn't working label Mar 4, 2025
@karthiknadig karthiknadig transferred this issue from microsoft/vscode Mar 4, 2025
@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Mar 4, 2025
@karthiknadig
Copy link
Member

Created this microsoft/vscode-python-debugger#647 to track support for nushell no-config debugging. PRs welcome on that, since it is a smallish feature, to enable debugging with VS Code directly from terminal without any configuration.

@rchiodo
Copy link
Contributor

rchiodo commented Mar 4, 2025

I don't think debugpy is adding the &&. That's likely VS code or the extension.

Here's the command I see in my terminal:

PS C:\Users\rchiodo\source\testing\test_pylance>  c:; cd 'c:\Users\rchiodo\source\testing\test_pylance'; ${env:DEBUGPY_LOG_DIR}='c:\Users\rchiodo\.vscode\extensions\ms-python.debugpy-2025.0.1-win32-x64'; & 'c:\Users\rchiodo\source\testing\test_pylance\.venv313\Scripts\python.exe' 'c:\Users\rchiodo\.vscode\extensions\ms-python.debugpy-2025.0.1-win32-x64\bundled\libs\debugpy\launcher' '56288' '--' 'C:\Users\rchiodo\source\testing\test_pylance\test_debugging.py' 

Here's the actual request from debugpy:

             Client[1] <-- {
                 "seq": 7,
                 "type": "request",
                 "command": "runInTerminal",
                 "arguments": {
                     "kind": "integrated",
                     "title": "Python Debug Console",
                     "args": [
                         "c:\\Users\\rchiodo\\source\\testing\\test_pylance\\.venv313\\Scripts\\python.exe",
                         "c:\\Users\\rchiodo\\.vscode\\extensions\\ms-python.debugpy-2025.0.1-win32-x64\\bundled\\libs\\debugpy\\launcher",
                         "56288",
                         "--",
                         "C:\\Users\\rchiodo\\source\\testing\\test_pylance\\test_debugging.py"
                     ],
                     "env": {
                         "DEBUGPY_LOG_DIR": "c:\\Users\\rchiodo\\.vscode\\extensions\\ms-python.debugpy-2025.0.1-win32-x64"
                     },
                     "cwd": "c:\\Users\\rchiodo\\source\\testing\\test_pylance"
                 }

@karthiknadig
Copy link
Member

@anthonykim1 Can you take a look?

@karthiknadig
Copy link
Member

@rchiodo I will move it to the right place after @anthonykim1 confirms. I didn;t realize that debugpy sent back plain args. I presumed we do this here because we have shell escape support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs repro Issue has not been reproduced yet
Projects
None yet
Development

No branches or pull requests

7 participants