Skip to content

fix: do not pass redundant quotes to script path in executeUsingExtension (#26274) - #26276

Merged
Eduardo Villalpando Mello (edvilme) merged 3 commits into
microsoft:mainfrom
wasim-builds:fix-26274-run-file-path-spaces
Nov 16, 2026
Merged

Eduardo Villalpando Mello (edvilme) merged 3 commits into
microsoft:mainfrom
wasim-builds:fix-26274-run-file-path-spaces

Conversation

@wasim-builds

Copy link
Copy Markdown

Summary

Fixes #26274
Also resolves the underlying issue reported upstream in microsoft/vscode#346333.

When "Run Python File" or "Run Python File in Dedicated Terminal" executes via the Python Environments extension API (extapi.runInTerminal or extapi.runInDedicatedTerminal), PythonTerminalExecutionOptions.args expects raw arguments and handles necessary shell quoting internally.

Previously, executeUsingExtension in src/client/terminals/codeExecution/codeExecutionManager.ts appended fileToExecute.fsPath.fileToCommandArgumentForPythonExt() to totalArgs. For script paths containing spaces (e.g. /path with spaces/main.py), fileToCommandArgumentForPythonExt() wrapped the path in literal quotes ("..."). When passed to runInTerminal, the terminal received literal quotes as part of the path, causing Python to fail with [Errno 2] No such file or directory or [Errno 22] Invalid argument: '"/path with spaces/main.py"'.

Changes

  1. In src/client/terminals/codeExecution/codeExecutionManager.ts:
    • Pass raw fileToExecute.fsPath in totalArgs instead of wrapping with fileToCommandArgumentForPythonExt(), letting the terminal execution API handle argument quoting.
  2. In src/test/terminals/codeExecution/codeExecutionManager.unit.test.ts:
    • Added unit test Ensure executeUsingExtension does not pass extra quotes in path with spaces.
    • Added unit test Ensure executeUsingExtension does not pass extra quotes in path with spaces for dedicated terminal.

Verification

  • npx tsc -p ./ passed with 0 errors.
  • npx mocha -r out/test/unittests.js --ui tdd out/test/terminals/codeExecution/codeExecutionManager.unit.test.js passed all 12 tests.
  • npx eslint src/client/terminals/codeExecution/codeExecutionManager.ts src/test/terminals/codeExecution/codeExecutionManager.unit.test.ts passed with 0 errors and 0 warnings.

Copilot AI balanced review requested due to automatic review settings November 5, 2026 19:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@edvilme

Copy link
Copy Markdown

Thank you very much for taking on this, changes look good and reasonable to me. I will let the tests run and let you know if there are any news! Thanks!

@edvilme Eduardo Villalpando Mello (edvilme) added the bug Issue identified by VS Code Team member as probable bug label Nov 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the change addressing script execution for paths containing spaces.

No open issues 🎉

Review effort: Balanced

@edvilme
Eduardo Villalpando Mello (edvilme) merged commit 50cde3d into microsoft:main Nov 16, 2026
52 checks passed
@edvilme

Copy link
Copy Markdown

Hello MOHAMMED WASIM KHAN (@wasim-builds) Thank you very much for taking the time to work on this and addressing the bug. Changes look good :)

@wasim-builds

Copy link
Copy Markdown
Author

Eduardo Villalpando Mello (@edvilme) thank you for appreciation, is there any way to join the organisation and work , if there any opportunities please let me know it will be very helpful for me , once again thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue identified by VS Code Team member as probable bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Run Python File passes literal quotes in script path to terminal

5 participants