Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 #5132

Open
6 tasks done
thegraffix opened this issue Jan 25, 2025 · 1 comment
Labels
Issue-Bug A bug to squash. Needs: Triage Maintainer attention needed!

Comments

@thegraffix
Copy link

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.createTemporaryIntegratedConsole is enabled
  • settings.json or launch.json contains cwd value 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

Steps to Reproduce

  • Enable powershell.debugging.createTemporaryIntegratedConsole
  • Edit/Run a .ps1 script (F5) that's stored on a drive that's different from the cwd value in settings.json or launch.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 $PSScriptRoot when it shouldn't be changed at all

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

@thegraffix thegraffix added Issue-Bug A bug to squash. Needs: Triage Maintainer attention needed! labels Jan 25, 2025
Copy link

We've found some similar issues:

If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.

Note: You can give me feedback by 👍 or 👎 this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug A bug to squash. Needs: Triage Maintainer attention needed!
Projects
None yet
Development

No branches or pull requests

1 participant