Skip to content

python.terminal.executeInFileDir doesn't work if file is on another drive from working directory #14730

@peachthiefmedia

Description

@peachthiefmedia

Environment data

  • VS Code version: 1.51.1
  • Extension version (available under the Extensions sidebar): 2020.11.358366026
  • OS and version: Windows 10.0.19042
  • Python version (& distribution if applicable, e.g. Anaconda): Anaconda Python 3.6.12 64-bit
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda
  • Relevant/affected Python packages and their versions: NA
  • Relevant/affected Python-related VS Code extensions and their versions: NA
  • Value of the python.languageServer setting: Pylance

Expected behaviour

Expect that if the file directory is on a different drive to the working directory and "python.terminal.executeInFileDir" is set to true, that the terminal will change drive, then change directory, then run python file

Actual behaviour

Terminal opens, changes directory and then runs python file

Steps to reproduce:

  1. Have python.terminal.executeInFileDir = True
  2. Open python file on drive other than working directory
  3. Run python file in terminal

Terminal will open, run the 'cd FileDir' command but not change drive, and then run the python file

Related Code

Related code appears to be in terminalCodeExecution.ts

if ((!wkspace || fileDirPath !== wkspace.uri.fsPath) && fileDirPath.length > 0) { await this.getTerminalService(file).sendText(`cd ${fileDirPath.fileToCommandArgument()}`); }

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions