Skip to content

set python.terminal.executeInFileDir not working, python file run earlier than cd command #835

Description

@kaala

Behaviour

I expect set python.terminal.executeInFileDir=true will let run python file command run under the file dir, but the terminal is first execute the python file, then change to file dir.
the button is not working on the first run.

PS, report bug is also not working.
report bug jump to a instruction page, instruct to create bug from vscode.
but from vscode, click preview button jump to issue template select dialog.
loop forever.

Steps to reproduce:

  1. close all running terminal
  2. create a folder, and add a py file
  3. print(os.getcwd())
  4. click run python file button
  5. the terminal print the workspace dir, and after execute the py file, the terminal change to the file location.

Image

Diagnostic data

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

import os
print("current dir", os.getcwd())
source /workspace/runner/venv/bin/activate
root ➜ /workspace/runner (master) $ source /workspace/runner/venv/bin/activate
(venv) root ➜ /workspace/runner (master) $ /workspace/runner/venv/bin/python -B /workspace/runner/demo/r.py
cd /workspace/runner/demo
current dir /media/workspace/runner
(venv) root ➜ /workspace/runner (master) $ cd /workspace/runner/demo
(venv) root ➜ /workspace/runner/demo (master) $ 

Activity

  1. karthiknadig commented on Apr 30, 2025

    @karthiknadig
    Member

    kaala (@kaala) Can you share the logs from Output > Python?

  2. added
    bugIssue identified by VS Code Team member as probable bug
    and removed
    feature-requestRequest for new features or functionality
    on May 1, 2025
  3. kaala commented on May 6, 2025

    @kaala
    Author

    output > python log seems no useful information.
    I only see send text to terminal.
    Image

  4. anthonykim1 commented on May 8, 2025

    @anthonykim1
    Contributor

    Can you set your log level to trace, and reproduce the behavior to get a more verbose log?
    Also which OS are you using, and which shell?

    Does it help if you turn off terminal.integrated.shellIntegration.enabled setting?

  5. kaala commented on May 13, 2025

    @kaala
    Author

    I use remotessh to linux server, ubuntu. and the shell is bash.
    I changed python log level to trace, and the output is the same, nothing new.
    I wasn't set terminal.integrated.shellIntegration.enabled, but set it to false seems fixed the problem.

  6. github-actions commented on Jun 12, 2025

    @github-actions

    Hey Anthony Kim (@anthonykim1), this issue might need further attention.

    kaala (@kaala), you can help us out by closing this issue if the problem no longer exists, or adding more information.

  7. lsccc6 commented on Jun 13, 2025

    @lsccc6

    same here. please fix!

  8. RaSan147 commented on Jul 12, 2025

    @RaSan147

    Issue persists
    Ext v2025.10.0
    VS Insider v1.103.0-insider

    It no longer changing dir. Running in root directory.
    Working in Run Python file in dedicated terminal (however inconsistent, keeps spawning too many terminals)

  9. github-actions commented on Aug 11, 2025

    @github-actions

    Hey Anthony Kim (@anthonykim1), this issue might need further attention.

    kaala (@kaala), you can help us out by closing this issue if the problem no longer exists, or adding more information.

  10. 3 remaining items

  11. added
    bugIssue identified by VS Code Team member as probable bug
    area-terminalEnvironment extension specific terminal issues.
    and removed on Dec 15, 2025
  12. anthonykim1 commented on Dec 15, 2025

    @anthonykim1
    Contributor

    Are folks still experiencing this?

  13. kaala commented on Dec 16, 2025

    @kaala
    Author

    Hi, the problem seems fixed in vscode 1.107.0.

  14. locked as resolved and limited conversation to collaborators on Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-terminalEnvironment extension specific terminal issues.bugIssue identified by VS Code Team member as probable bugconfirmation-pendingThe issue needs to be confirmed through a maintainer reproducing the bug.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions