8000 Default shell ("System default") caches a Store pwsh path for the whole session; every pane fails after a Store PowerShell update · Issue #334 · amirlehmam/wmux · GitHub
[go: up one dir, main page]

Skip to content

Default shell ("System default") caches a Store pwsh path for the whole session; every pane fails after a Store PowerShell update #334

Closed

Description

@hbjorn37

What happens

With "Default shell" left at System default, wmux resolves pwsh.exe once at startup and keeps that absolute path in cachedDefaultShell for the lifetime of the process. On a Store-installed PowerShell the resolved path is the versioned package directory behind the App Execution Alias, e.g.

C:\Program Files\WindowsApps\Microsoft.PowerShell_7.6.7.0_x64__8wekyb3d8bbwe\pwsh.exe

When the Store updates PowerShell while wmux is running, that directory is removed and replaced by a new versioned one. The cached path is never re-validated, so from that moment on every new pane fails with:

[failed to create PTY: Error: Error invoking remote method 'pty:create': Error: Failed to create terminal: File not found: C:\Program Files\WindowsApps\Microsoft.PowerShell_7.6.7.0_x64__8wekyb3d8bbwe\pwsh.exe]

Restarting wmux fixes it, until the next PowerShell update.

Expected: a pane create should notice the cached default-shell path is gone and re-resolve it, the same way the per-spec cache already does. resolveExistingShellPath() re-checks a cached hit with fs.existsSync before handing it back (its own comment says this is exactly to avoid feeding a dead path to pty.spawn), but getDefaultShell() returns cachedDefaultShell unconditionally, so the "System default" path has no such protection. The appExecAliasTarget comment also notes that "the alias survives a Store update, the versioned directory does not", but the default-shell cache stores the versioned target rather than the alias spelling.

Suggested fix (either is enough):

  • In getDefaultShell(), re-validate cachedDefaultShell with existsSync (or spawnablePath) and re-resolve on a miss, mirroring resolveExistingShellPath().
  • Or cache the spec (pwsh.exe / the alias path) instead of the resolved versioned exe, and resolve it through resolveExistingShellPath() on each create so the existing re-validation applies.

Workaround that works today: set Settings → Workspace → Default shell to PowerShell Core (pwsh.exe). That spec goes through resolveShell() → resolveExistingShellPath(), whose cache is re-validated, so panes keep working across Store updates.

Steps to reproduce

  1. Install PowerShell 7 from the Microsoft Store (not MSI), so pwsh.exe is only reachable via the App Execution Alias.
  2. In wmux Settings → Workspace, leave "Default shell" at System default. Open a workspace; panes open fine with pwsh.
  3. While wmux is running, let the Store update PowerShell to a new version (or trigger it via Microsoft Store → Library → Update). Note: the update only completes once no pwsh process from the old package is running, so close existing panes first or wait for the Store to retry.
  4. Open a new pane (or a new workspace).
  5. Observe the "File not found: C:\Program Files\WindowsApps\Microsoft.PowerShell__x64__8wekyb3d8bbwe\pwsh.exe" PTY error on every new pane. Restart wmux → panes work again.

In my case the timing was: wmux started 18:01:59, AppX deployment event for the PowerShell package fired at 18:02:00 (the update had been retried three times during the day and only went through when the previous wmux session and its pwsh processes exited). The alias and Get-AppxPackage Microsoft.PowerShell already pointed at 7.6.8 when I inspected them, so only wmux's in-memory cache was stale.

wmux version

2.38.0

Windows version

Windows 11 26300

Anything else

  • Shell: PowerShell 7.6.7 → 7.6.8, Store install (Microsoft.PowerShell_8wekyb3d8bbwe), no MSI install present.
  • settings.json has no shell setting (wmux-workspace-prefs.defaultShell unset → System default); every workspace has "shell": "".
  • session.json surfaces carry "resolvedShell": "...Microsoft.PowerShell_7.6.7.0_x64__8wekyb3d8bbwe\pwsh.exe" — as far as I can tell that is only used for the tab title and gets overwritten on a successful spawn, so it is a symptom, not the cause.
  • Related: This started happening after I updated powershell a few days ago. #299 (App Execution Alias resolution) and Boot performance #176 (shell path memoization). This report is the one remaining cache that Boot performance #176's re-validation does not cover.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0