Skip to content

Inconsistent behavior for working directory when running scripts #4082

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

Closed
5 of 6 tasks
fflaten opened this issue Jul 16, 2022 · 0 comments · Fixed by #4172
Closed
5 of 6 tasks

Inconsistent behavior for working directory when running scripts #4082

fflaten opened this issue Jul 16, 2022 · 0 comments · Fixed by #4172
Assignees
Labels

Comments

@fflaten
Copy link
Contributor

fflaten commented Jul 16, 2022

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

#3259 was recently fixed so the integrated console doesn't change CWD when using "Run/Debug Tests". However there are still commands and config that enforces and promotes unnecessary CWD-changes.

The first command should not change working directory in my opinion. The suggested launch config should also leave it unchanged (set to cwd: ""). People can change it if they want/need it.

This change would also encourage users to rely on $PSScriptRoot when referencing files relative to the script. I believe that's a good practice since working directory is rarely specified when running scripts in my experience.

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.2.5
PSEdition                      Core
GitCommitId                    7.2.5
OS                             Microsoft Windows 10.0.22000
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visual Studio Code Version

1.70.0-insider
1cd90cceddf3c413673963ab6f154d2ff294b17c
x64

Extension Version

Steps to Reproduce

Scenario 1:

  1. Create a powershell-file in a different directory than the integrated console's cwd/pwd
  2. Press the play-button or use PowerShell: Run command

Scenario 2:

  1. Add a launch configuration for Launch current file
  2. Press F5 in a powershell-file that's placed in a different folder than the integrated console's cwd/pwd

The cwd/pwd in integrated console will be changed.

Visuals

No response

Logs

No response

@fflaten fflaten added the Issue-Bug A bug to squash. label Jul 16, 2022
@ghost ghost added the Needs: Triage Maintainer attention needed! label Jul 16, 2022
@fflaten fflaten changed the title Inconsistent behavior for changing working directory Inconsistent behavior for working directory when running scripts Jul 17, 2022
@andyleejordan andyleejordan self-assigned this Jul 19, 2022
@SydneyhSmith SydneyhSmith added this to the Consider-vNext milestone Jul 20, 2022
@SydneyhSmith SydneyhSmith added Area-Debugging and removed Needs: Triage Maintainer attention needed! labels Jul 20, 2022
@SydneyhSmith SydneyhSmith removed this from the Consider-vNext milestone Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants