症状
Windows 11 に SSH 接続すると、Scoop で入れたコマンドが見つからなくなる現象が発生する。
git: The term 'git' is not recognized ...- oh-my-posh のプロンプトが反映されない
同じユーザーでローカルの Windows Terminal から PowerShell を開くと正常である。
原因
Scoop はバージョン切替に current を Junction(reparse point)として作るが、SSH セッションから current がトラバース不能になっていた。
GitHub の報告でも、current 配下を SSH 経由で実行すると「untrusted mount point を含むためパスを辿れない」となり、バージョン番号の付いた実体ディレクトリでは発生しない旨が書かれている。
当該のWindowsアップデートを削除すれば解決する
切り分け
SSH セッションで次を確認すると、実体は見えるのに current だけ壊れていることが分かる。
PS C:\Users\Admin> Test-Path C:\Users\Admin\scoop\apps\git\2.53.0\cmd\git.exe
True
PS C:\Users\Admin> Test-Path C:\Users\Admin\scoop\apps\git\current\cmd\git.exe
False
PS C:\Users\Admin> Get-Item C:\Users\Admin\scoop\apps\git\current -Force | Format-List FullName,Attributes,LinkType,Target
FullName : C:\Users\Admin\scoop\apps\git\current
Attributes : ReadOnly, Directory, ReparsePoint, NotContentIndexed
LinkType : Junction
Target : C:\users\admin\scoop\apps\git\2.53.0
解決手順
管理者権限のターミナル(PowerShell でも cmd でも可)で実行する。
wusa /uninstall /kb:5077181
Windows再起動
wusa /uninstall /kb:5074105
再度Windows を再起動
参考
[Bug] The current junction folder cannot be accessed over SSH since KB5074105 #6594