Running script with F5 changes directory when script is on a drive that's different from launch.json cwd value and powershell.debugging.createTemporaryIntegratedConsole is enabled
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- powershell, typescript
- Domain
- developer-experience, devtools
Research direction
Reproduce the issue with powershell.debugging.createTemporaryIntegratedConsole enabled, a cwd of C:, and a script on another drive, then inspect the integrated terminal directories before and after pressing F5. Trace the temporary integrated console and debug launch path responsible for changing the script drive's directory. Done means the script runs while that drive's existing current directory remains unchanged.
Written by the indexing model from the issue text.
Description
Prerequisites
- I have written a descriptive issue title.
- I have searched all open and closed issues to ensure it has not already been reported.
- I have read the troubleshooting guide.
- I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
- I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
- If this is a security issue, I have read the security issue reporting guidance.
Summary
Scenario:
powershell.debugging.createTemporaryIntegratedConsoleis enabledsettings.jsonorlaunch.jsoncontainscwdvalue of"C:\\"- Editor:
D:\Scripts\MyScript.ps1
Integrated Terminal current directories:
Before running D:\Scripts\MyScript.ps1 with F5:
| Drive | Current Directory | Is $PWD? |
|---|---|---|
C: |
C:\Users\TestUser\Desktop\ |
NO |
D: |
D:\ |
YES |
After running D:\Scripts\MyScript.ps1 with F5:
| Drive | Current Directory | Is $PWD? |
|---|---|---|
C: |
C:\ |
YES |
D: |
D:\Scripts\ <--- bug (should remain D:\) |
NO |
PowerShell Version
Name Value
---- -----
PSVersion 7.5.0
PSEdition Core
GitCommitId 7.5.0
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Name : Visual Studio Code Host
Version : 2025.0.0
InstanceId : e0913dbc-6176-4e70-9bd3-1d5b63449f20
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : en-US
CurrentUICulture : en-US
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled : True
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace
Visual Studio Code Version
1.96.4
cd4ee3b1c348a13bafd8f9ad8060705f6d4b9cba
x64
Extension Version
ms-vscode.powershell@2025.0.0
Steps to Reproduce
- Enable
powershell.debugging.createTemporaryIntegratedConsole - Edit/Run a .ps1 script (F5) that's stored on a drive that's different from the
cwdvalue insettings.jsonorlaunch.json - When script is finished running, inspect the current directory of the drive on which the .ps1 script is stored
- That drive's current directory will be set to
$PSScriptRootwhen it shouldn't be changed at all
- That drive's current directory will be set to
Expected behavior:
- The cd for the drive on which the .ps1 script is stored should not be changed
Actual behavior:
- The cd for the drive on which the .ps1 script is stored gets changed to:
$PSScriptRoot
Visuals
No response
Logs
No response
- Dominant language
- TypeScript
- Stars
- 1.9k
- Forks
- 548
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PowerShell/vscode-powershell
-
agentic-workflows
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
PowerShell/vscode-powershell#5599 · 3 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
PowerShell/vscode-powershell#5592 · 2 comments · 1 reaction ·
-
agentic-workflows
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
PowerShell/vscode-powershell#5583 · 1 comment ·
-
powershell.scriptAnalysis.settingsPath (Description): Warning Message Should Provide A Workaround OpenArea-Code Formatting Issue-Enhancement
Difficulty 1/5 Under an hour Newbie friendliness 68/100
PowerShell/vscode-powershell#4653 · 3 comments · 4 reactions ·
-
nothing OpenIssue-Bug Needs: Triage
Difficulty 5/5 Over a week Newbie friendliness 5/100
PowerShell/vscode-powershell#5603 · 1 reaction ·
All issues in PowerShell/vscode-powershell
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
ontola/atomic-server#1625 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
melgarafael/DeskcommCRM#1451 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
-
bug via-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bot:ai-assisted component:compact-js status:untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
midnightntwrk/midnight-sdk#403 ·