Skip to content

"Run python file in terminal" does not respect cwd configuration #613

@Mithrillion

Description

@Mithrillion

Type: Bug

Behaviour

When checking the "Use Environments Extension" option, "run Python file in terminal" will use conda run command to execute the file. However, it will always execute the file in workspace root and not the file directory even when "cwd": "${fileDirname}", option is configured in launch.json. This causes relative paths in scripts meant to be executed from file directory to be invalid.

Steps to reproduce:

  1. Set "cwd": "${fileDirname}", in launch.json.
  2. Check "Use Environments Extension" in Python settings.
  3. In a python script, read a file using relative path starting from the file directory. e.g. np.load("data/test.npy")
  4. Right click and choose "run Python file in terminal"

Diagnostic data

launch.json configuration

XXX

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

XXX

Output for Python Debugger in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python Debugger)

XXX

Extension version: 0.3.11971010
VS Code version: Code 1.102.1 (7adae6a56e34cb64d08899664b814cf620465925, 2025-07-15T16:41:17.147Z)
OS version: Linux x64 6.15.6-1-default
Modes:

System Info
Item Value
CPUs AMD Ryzen 9 3950X 16-Core Processor (32 x 4130)
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: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
webnn: disabled_off
Load (avg) 4, 3, 2
Memory (System) 62.69GB (49.16GB free)
Process Argv --crash-reporter-id 3100afbf-018b-455d-96a1-4d73a707463e
Screen Reader no
VM 0%
DESKTOP_SESSION plasmawayland
XDG_CURRENT_DESKTOP KDE
XDG_SESSION_DESKTOP KDE
XDG_SESSION_TYPE wayland
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyt551cf:31249601
binariesv615:30325510
962ge761:30959799
h48ei257:31000450
nativeloc1:31344060
5fd0e150:31155592
dwcopilot:31170013
6074i472:31201624
dwoutputs:31242946
hdaa2157:31222309
copilot_t_ci:31333650
e5gg6876:31282496
pythoneinst12:31285622
c7cif404:31314491
pythonpulldiag:31343502
996jf627:31283433
pythonrdcb7:31342333
usemplatestapi:31297334
0aa6g176:31307128
747dc170:31275177
6518g693:31334701
aj953862:31281341
generatesymbolt:31295002
convertfstringf:31295003
pylancequickfixf:31329273
9d2cg352:31346308
usemarketplace:31343026
nesew2to5:31336538
agentclaude:31335815
nes-diff-11:31337487
2j0jg872-first:31348500
replacestringexc:31348966
6abeh943:31336334
yijiwantestdri0626-c:31336931
4gdec884:31348710

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions