Open jamesdolan opened 5 months ago
This looks like a bug with VS Code task launching. It seems to occur even if I manually quote the path.
Using a custom shell configuration in tasks.json
, I thought I had this problem, caused by a VSCode update. But it turned to be a problem with a Visual Studio 2022 update that happened at the same time--which made the file I was referencing (vcvarsall.bat
) go missing:
"shell": {
"executable": "cmd.exe",
"args": [
"/C",
"\"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvarsall.bat\"",
"amd64",
"&&"
]
}
When vcvarsall.bat
vanished off disk, the error in VSCode terminal I was getting said:
'C:/Program' is not recognized as an internal or external command, operable program or batch file.
But when the file reappeared (after running repair installation on Visual Studio), everything went back to working fine.
Just throwing that in: that the error messages here may be misleading, making you think the failure is in the space preservation, when it's some other error. In my case, cmd.exe
doesn't know how to report paths with spaces as an error when used in this way, so there's nothing VSCode can really do about it.
{
"tasks": [
{
"label": "python server",
"type": "shell",
"command": "${command:python.interpreterPath}",
"args": [
"-m",
"http.server",
],
},
],
}
Executing task: "C:\Program Files\Python312\python.exe" -m http.server
C:\Program : The term 'C:\Program' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command "C:\Program Files\Python312\python.exe" -m http.server" terminated with exit code: 1.
I tried running
C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command "C:\Program Files\Python312\python.exe" -m http.server
by itself and got the same 'C:\Program' is not recognized
error
Type: Bug
Behaviour
After updating VSCode for Windows today my project now fails to run any python-based tasks apparently due to spaces in the
${command:python.interpreterPath}
path. The tasks themselves or theworkspaceFolder
have not changes in many months (years?) so it appears vscode or the python plugin changes have broken recently. Possibly related to https://github.com/microsoft/vscode-python/issues/23028Steps to reproduce:
My
tasks.json
Test Python
taskDiagnostic data
Task fails to run, dialog prompt opens titled:
Select an App to open 'James'
... due to spaces not being properly escaped/quoted? The file is a large log that I have not had time to sanitize yet. But also not very useful, the fact that the filename is my first name tells me its not escaping spaces correctly in the workspace path (which is in my home directory on windows).If I replace
"command": "${command:python.interpreterPath}"
with"command": "python"
the task succeeds, and the correct path is printed. But as far as I am aware, this is not the canonical way of specifying the correct python executable, and its unclear if this will cause issue in future versions of vscode and/or other platforms.Extension version: 2024.8.0 VS Code version: Code 1.90.0 (89de5a8d4d6205e5b11647eb6a74844ca23d2573, 2024-06-04T19:33:54.889Z) OS version: Windows_NT x64 10.0.22631 Modes:
python.languageServer
setting: DefaultUser Settings
``` languageServer: "Pylance" ```
Installed Extensions
|Extension Name|Extension Id|Version| |---|---|---| |Black Formatter|ms-python.black-formatter|2024.2.0| |C/C++|ms-vscode.cpptools|1.20.5| |C/C++ Extension Pack|ms-vscode.cpptools-extension-pack|1.3.0| |C/C++ Themes|ms-vscode.cpptools-themes|2.0.0| |CMake|twxs.cmake|0.0.17| |CMake Tools|ms-vscode.cmake-tools|1.18.41| |Graphviz Interactive Preview|tintinweb.graphviz-interactive-preview|0.3.5| |JavaScript Debugger|ms-vscode.js-debug|1.90.0| |JavaScript Debugger Companion Extension|ms-vscode.js-debug-companion|1.1.2| |Jupyter|ms-toolsai.jupyter|2024.5.0| |Jupyter Cell Tags|ms-toolsai.vscode-jupyter-cell-tags|0.1.9| |Jupyter Keymap|ms-toolsai.jupyter-keymap|1.1.2| |Jupyter Notebook Renderers|ms-toolsai.jupyter-renderers|1.0.18| |Jupyter Slide Show|ms-toolsai.vscode-jupyter-slideshow|0.1.6| |Makefile Tools|ms-vscode.makefile-tools|0.9.10| |Mypy Type Checker|ms-python.mypy-type-checker|2023.9.11501016| |Pylance|ms-python.vscode-pylance|2024.6.1| |Python|ms-python.python|2024.8.0| |Python Debugger|ms-python.debugpy|2024.7.11591013| |Sort lines|Tyriar.sort-lines|1.11.0| |Table Visualizer for JavaScript Profiles|ms-vscode.vscode-js-profile-table|1.0.9|System Info
|Item|Value| |---|---| |CPUs|13th Gen Intel(R) Core(TM) i9-13900K (32 x 2995)| |GPU Status|2d_canvas: enabledcanvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|127.77GB (117.38GB free)| |Process Argv|--crash-reporter-id b8f68be3-ab48-4123-848a-81629c1f3d36| |Screen Reader|no| |VM|0%|
A/B Experiments
``` vsliv368cf:30146710 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscod805cf:30301675 binariesv615:30325510 vsaa593:30376534 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 962ge761:30959799 pythongtdpath:30769146 welcomedialogc:30910334 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30898717 pythontestfixt:30902429 pythonregdiag2:30936856 pythonmypyd1:30879173 pythoncet0:30885854 h48ei257:31000450 pythontbext0:30879054 accentitlementsc:30995553 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 jchc7451:31067544 chatpanelc:31048052 dsvsc021:30996838 jg8ic977:31013176 pythoncenvpt:31062603 a69g1124:31058053 dvdeprecation:31068756 pythonprt:31056678 dwnewjupyter:31046869 26j00206:31048877 ```