[BUG] Integrated Powershell Console does not autostart if "powershell.cwd" is set to "${workspaceFolder}"

Đang mở
#5,462 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
55/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
powershell, vscode

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện vấn đề với các cài đặt code-workspace được cung cấp và so sánh hành vi khởi động khi có và không đặt powershell.cwd thành ${workspaceFolder}. Đọc cách PowerShell extension xử lý việc khởi động integrated console và khởi động lại session, sử dụng các log đầu ra PowerShell được cung cấp làm bằng chứng. Hoàn thành có nghĩa là automatic startup, thư mục workspace được cấu hình, Rich Shell Integration, IntelliSense và Restart Powershell Session đều hoạt động cùng nhau.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Issue-Bug Needs: Triage
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
  1. Create a new folder in your dev drive or dev directory
  2. Create a new code-workspace file 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"
            ]
         }
      }
   }
}
  1. Open the workspace in VS Code.
  2. Open a powershell file from the file picker
  3. Observe that the integrated powershell terminal (Shell Integration: Rich) does not automatically open and the "Restart Powershell Session" command does nothing.
  4. Comment out the "powershell.cwd": "${workspaceFolder}" line in your code-workspace file.
  5. Now reopen the same workspace.
  6. Observe the powershell integrated terminal now opens automatically (but does not navigate to ${workspaceFolder}.
  7. 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.
Ngôn ngữ chính
TypeScript
Star
1.9k
Fork
548
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của PowerShell/vscode-powershell

Tất cả issue của PowerShell/vscode-powershell

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.