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

Improve documentation and provide examples for "args": "${command:pickArgs}" and "args": ["${command:pickArgs}"] #23003

Closed
SwordTechCorp opened this issue Feb 29, 2024 · 3 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug documentation needs PR Ready to be worked on

Comments

@SwordTechCorp
Copy link

Type: Bug

Behaviour

Expected vs. Actual

Expected:
"args": ["${command:pickArgs}"]
Actuall:
"args": "${command:pickArgs}"

Steps to reproduce:

  1. Activate Python Extension and create new launch.json file

  2. Click Add Configuration, select Python Debugger -> Python File with Arguments

Without representing args as an array, the paths sent to the terminal will not be enclosed by quotes and launch will fail if there is a space in the path.

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.11.4
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
  • Value of the python.languageServer setting: Default
Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

XXX

User Settings


languageServer: "Pylance"

Extension version: 2024.2.0
VS Code version: Code 1.87.0 (019f4d1419fbc8219a181fab7892ebccf7ee29a2, 2024-02-27T23:41:44.469Z)
OS version: Windows_NT x64 10.0.22621
Modes:

System Info
Item Value
CPUs AMD Ryzen 7 4800H with Radeon Graphics (16 x 2895)
GPU Status 2d_canvas: enabled
canvas_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) 15.36GB (5.79GB free)
Process Argv --crash-reporter-id 2167e4d6-9976-4c5a-bc63-a6fb896ad659
Screen Reader no
VM 20%
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscorecescf:30445987
vscod805cf:30301675
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:30899288
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
pythongtdpath:30769146
welcomedialogc:30910334
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
h48ei257:30968133
pythontbext0:30879054
accentitlementst:30887150
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
pydisww2:30959801
d34g3935:30971562
edj9j583:30969295
a89i1917:30973842
e3gdj431:30958358
ccp1r3:30958155
dsvsc020:30973508

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Feb 29, 2024
@macintacos
Copy link

macintacos commented Mar 1, 2024

This issue just literally saved me a huge headache, thank you so much.

I just read about pickArgs in the documentation, and I was banging my head against a wall trying to figure out why I couldn't debug a CLI application properly (I'd do something like pass an option in my program + it's value, and the whole option+value was being interpreted as a string instead of separate arguments for the command). Removing the brackets solved it, and now it's properly parsing and debugging things like I expect.

Really think it's worth updating the documentation to make this more obvious. The mention of pickArgs is right under a code example that shows args values in brackets, so I had incorrectly assumed that the same syntax would be required.

@rwarren
Copy link

rwarren commented Sep 3, 2024

For others landing here because ${command:pickArgs} is collecting all your args into a single string (len(sys.argv) == 2), this is the line you want:

            "args": "${command:pickArgs}",

As previously stated, there are no square brackets on this line.

@karthiknadig karthiknadig added bug Issue identified by VS Code Team member as probable bug documentation needs PR Ready to be worked on and removed triage-needed Needs assignment to the proper sub-team labels Dec 8, 2024
@karthiknadig karthiknadig changed the title [launch.json] Incorrect default value for "args" of configuration "Python Debugger: Current File with Arguments" Improve documentation and provide examples for "args": "${command:pickArgs}" and "args": ["${command:pickArgs}"] Dec 8, 2024
@cwebster-99
Copy link
Member

Updated docs in microsoft/vscode-docs#7853

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 documentation needs PR Ready to be worked on
Projects
None yet
Development

No branches or pull requests

8 participants
@rwarren @karthiknadig @macintacos @paulacamargo25 @SwordTechCorp @luabud @cwebster-99 and others