python.terminal.executeInFileDir doesn't work if file is on another drive from working directory
See original GitHub issueEnvironment 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:
- Have python.terminal.executeInFileDir = True
- Open python file on drive other than working directory
- 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()}`); }
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to run python interactive in current file's directory in ...
In "User Settings", use the search bar to look for "python.terminal.executeInFileDir" and set (=) its value to "true" instead of "false".
Read more >Running Python Scripts from the Command Line
Type it now and see that the contents are the same as if you opened the "C:" drive in windows. Another command is...
Read more >Python in Visual Studio Code – November 2021 Release
We are pleased to announce that the November 2021 release of the Python Extension for Visual Studio Code is now available.
Read more >Visual Studio Code - Opening Files with Python open()
When running Python files using Run Python File in Terminal, Visual Studio Code runs the Pythn file using an absolute path.
Read more >Generating a List of Files – Python for AV - GitHub Pages
If you plug in an external drive, it is probably mounted as a folder in ... If you find code in this workshop...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’d like to start solving this issue
I see an issue here, running a file in a different drive works. but then when you run a file in the same dir as the workspace, it does not work. It does not restore the directory.
After step 5 of verification, run a python file from the workspace. it sends a
cd
but not a drive change.