PowerShell / PowerShell/vscode-powershell
[BUG] Integrated Powershell Console does not autostart if "powershell.cwd" is set to "${workspaceFolder}"
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 1.9k
- Forks
- 548
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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
In my Powershell code-workspace, I have the following defined:
{
"folders": [
{
"path": "."
}
],
"settings": {
"terminal.integrated.cwd": "${workspaceFolder}",
"powershell.cwd": "${workspaceFolder}",
"powershell.startAutomatically": true,
"powershell.integratedConsole.showOnStartup": true,
"files.defaultLanguage": "powershell",
"terminal.integrated.profiles.windows": {
"PowerShell": {
"path": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
"args": [
"-noexit",
"-Command",
"Import-Module FMDevToolbox -Force"
]
}
}
}
}
When opening my workspace, the integrated powershell terminal does not automatically open like it used to. It should automatically open per the "powershell.startAutomatically": true entry, but it doesn't. I don't know for sure, but this seems to be a regression with the latest update to VSCode (v1.115). It could be something else though.
If I comment out the "powershell.cwd" line in my workspace file, then PowerShell DOES correctly start automatically. But not in my workspace folder.
After investigating further, I've modified my workspace config to comment out the "powershell.cwd" line, and the integrated terminal starts automatically.
Working Config:
{
"folders": [
{
"path": "."
}
],
"settings": {
"terminal.integrated.cwd": "${workspaceFolder}",
// "powershell.cwd": "${workspaceFolder}",
"powershell.startAutomatically": true,
"powershell.integratedConsole.showOnStartup": true,
"files.defaultLanguage": "powershell",
"terminal.integrated.profiles.windows": {
"PowerShell": {
"path": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
"args": [
"-noexit",
"-Command",
"Import-Module FMDevToolbox -Force"
]
}
}
}
}
Unfortunately now powershell doesn't automatically open to my ${workspaceFolder}, and nor do I get a terminal with Rich Shell Integration.
The rich terminal shows the following on hover:
PowerShell Extension
Process ID (PID): 61316
Command line: …\pwsh.exe -NoProfile -ExecutionPolicy Bypass -Command 'Import-Module 'c:\Users\futur.vscode\extensions\ms-vscode.powershell-2025.4.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2025.4.0' -BundledModulesPath 'c:\Users\futur.vscode\extensions\ms-vscode.powershell-2025.4.0\modules' -EnableConsoleRepl -StartupBanner '' -LogLevel 'Warning' -LogPath 'c:\Users\futur\AppData\Roaming\Code\logs\20260408T203902\window1\exthost\ms-vscode.powershell' -SessionDetailsPath 'c:\Users\futur\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\sessions\PSES-VSCode-21824-689089.json' -FeatureFlags @() '
Shell integration: Rich
If the "powershell.cwd": "${workspaceFolder}" line isn't commented out, I don't get Rich Shell Integration and Intellisense doesn't work at all.
Can someone on the VSCode Powershell team check if this behavior is happening to them or any other users? I'd really like to keep my "powershell.cwd": "${workspaceFolder}" config definition so the terminal opens to my workspace folder.
PowerShell Version
2026-04-08 21:13 D:\Dev\Powershell> $PSVersionTable; $Host
Name Value
---- -----
PSVersion 7.6.0
PSEdition Core
GitCommitId 7.6.0
OS Microsoft Windows 10.0.26200
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.4
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Name : Visual Studio Code Host
Version : 2025.4.0
InstanceId : 30a174ff-c438-4026-abff-a11575e920c4
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.115.0
41dd792b5e652393e7787322889ed5fdc58bd75b
x64
Extension Version
ms-vscode.powershell@2025.4.0
Steps to Reproduce
- Create a new folder in your dev drive or dev directory
- Create a new
code-workspacefile inside this folder with the following contents:
{
"folders": [
{
"path": "."
}
],
"settings": {
"terminal.integrated.cwd": "${workspaceFolder}",
"powershell.cwd": "${workspaceFolder}",
"powershell.startAutomatically": true,
"powershell.integratedConsole.showOnStartup": true,
"files.defaultLanguage": "powershell",
"terminal.integrated.profiles.windows": {
"PowerShell": {
"path": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
"args": [
"-noexit"
]
}
}
}
}
- Open the workspace in VS Code.
- Open a powershell file from the file picker
- Observe that the integrated powershell terminal (Shell Integration: Rich) does not automatically open and the "Restart Powershell Session" command does nothing.
- Comment out the
"powershell.cwd": "${workspaceFolder}"line in yourcode-workspacefile. - Now reopen the same workspace.
- Observe the powershell integrated terminal now opens automatically (but does not navigate to
${workspaceFolder}. - The "Restart Powershell Session" command now works properly.
Visuals
Here's a screen recording showing the bugged behavior:
https://github.com/user-attachments/assets/418d2bbd-468c-4b5e-b465-10b827e3584e
Logs
Powershell log from the "Output" tab with "PowerShell" selected in the dropdown:
2026-04-08 21:08:12.542 [info] Visual Studio Code: v1.115.0 64-bit on Windows 64-bit
2026-04-08 21:08:12.542 [info] PowerShell Extension: v2025.4.0
2026-04-08 21:08:12.573 [info] Starting 'PowerShell (x64)' at: C:\Program Files\PowerShell\7\pwsh.exe
2026-04-08 21:08:12.742 [info] PowerShell process started with PID: 23800
2026-04-08 21:08:15.205 [info] Started PowerShell v7.6.0.
2026-04-08 21:08:15.782 [info] PowerShell is up-to-date.
2026-04-08 21:08:28.901 [info] Restarting session...
2026-04-08 21:08:28.928 [info] Starting 'PowerShell (x64)' at: C:\Program Files\PowerShell\7\pwsh.exe
2026-04-08 21:08:29.039 [warning] PowerShell process terminated or Extension Terminal was closed, PID: undefined
2026-04-08 21:08:38.093 [info] Restarting session...
2026-04-08 21:08:38.095 [info] Starting 'PowerShell (x64)' at: C:\Program Files\PowerShell\7\pwsh.exe
2026-04-08 21:08:38.203 [warning] PowerShell process terminated or Extension Terminal was closed, PID: undefined
2026-04-08 21:08:38.574 [info] Restarting session...
2026-04-08 21:08:38.583 [info] Starting 'PowerShell (x64)' at: C:\Program Files\PowerShell\7\pwsh.exe
2026-04-08 21:08:38.694 [warning] PowerShell process terminated or Extension Terminal was closed, PID: undefined
2026-04-08 21:08:38.728 [info] Restarting session...
2026-04-08 21:08:38.736 [info] Starting 'PowerShell (x64)' at: C:\Program Files\PowerShell\7\pwsh.exe
2026-04-08 21:08:38.847 [warning] PowerShell process terminated or Extension Terminal was closed, PID: undefined
2026-04-08 21:08:38.872 [info] Restarting session...
2026-04-08 21:08:38.881 [info] Starting 'PowerShell (x64)' at: C:\Program Files\PowerShell\7\pwsh.exe
2026-04-08 21:08:38.991 [warning] PowerShell process terminated or Extension Terminal was closed, PID: undefined
2026-04-08 21:08:38.992 [info] Restarting session...
2026-04-08 21:08:39.000 [info] Starting 'PowerShell (x64)' at: C:\Program Files\PowerShell\7\pwsh.exe
2026-04-08 21:08:39.105 [warning] PowerShell process terminated or Extension Terminal was closed, PID: undefined
2026-04-08 21:09:02.722 [info] Restarting session...
2026-04-08 21:09:02.729 [info] Starting 'PowerShell (x64)' at: C:\Program Files\PowerShell\7\pwsh.exe
2026-04-08 21:09:02.879 [info] PowerShell process started with PID: 121984
2026-04-08 21:09:04.193 [info] Started PowerShell v7.6.0.
2026-04-08 21:09:04.646 [info] PowerShell is up-to-date.
2026-04-08 21:13:31.306 [info] Restarting session...
2026-04-08 21:13:31.347 [info] Starting 'PowerShell (x64)' at: C:\Program Files\PowerShell\7\pwsh.exe
2026-04-08 21:13:31.452 [warning] PowerShell process terminated or Extension Terminal was closed, PID: undefined
2026-04-08 21:13:37.709 [info] Restarting session...
2026-04-08 21:13:37.713 [info] Starting 'PowerShell (x64)' at: C:\Program Files\PowerShell\7\pwsh.exe
2026-04-08 21:13:37.832 [warning] PowerShell process terminated or Extension Terminal was closed, PID: undefined
2026-04-08 21:13:47.307 [info] Restarting session...
2026-04-08 21:13:47.315 [info] Starting 'PowerShell (x64)' at: C:\Program Files\PowerShell\7\pwsh.exe
2026-04-08 21:13:47.467 [info] PowerShell process started with PID: 104268
2026-04-08 21:13:48.744 [info] Started PowerShell v7.6.0.
2026-04-08 21:13:49.123 [info] PowerShell is up-to-date.
2026-04-08 21:26:22.525 [info] Restarting session...
2026-04-08 21:26:22.541 [info] Starting 'PowerShell (x64)' at: C:\Program Files\PowerShell\7\pwsh.exe
2026-04-08 21:26:22.647 [warning] PowerShell process terminated or Extension Terminal was closed, PID: undefined
2026-04-08 21:27:09.546 [info] Restarting session...
2026-04-08 21:27:09.551 [info] Starting 'PowerShell (x64)' at: C:\Program Files\PowerShell\7\pwsh.exe
2026-04-08 21:27:09.716 [info] PowerShell process started with PID: 101156
2026-04-08 21:27:11.090 [info] Started PowerShell v7.6.0.
2026-04-08 21:27:11.542 [info] PowerShell is up-to-date.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, das Problem mit den bereitgestellten code-workspace-Einstellungen zu reproduzieren, und vergleiche das Startverhalten mit und ohne die auf ${workspaceFolder} gesetzte Einstellung powershell.cwd. Lies die Handhabung des Starts der integrierten Konsole und des Sitzungsneustarts der PowerShell extension und verwende die bereitgestellten PowerShell-Ausgabeprotokolle als Belege. Als abgeschlossen gilt die Aufgabe, wenn automatischer Start, das konfigurierte Arbeitsverzeichnis, Rich Shell Integration, IntelliSense und Restart Powershell Session zusammen funktionieren.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- powershell, vscode
- Bereich
- developer-experience, devtools
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 55/100