ScoopのアップデートでPowerShell(pwsh)が起動しているエラー

toc目次

Scoopのアップデートでエラー

ScoopでPowerShell 7(pwsh)のアップデートを実施すると以下のエラーが発生。

ERROR The following instances of "powershell" are still running.
Close them and try again.
ERROR Application "pwsh" is still running. Close all instances and try again.

PowerShellで実行しているのがまずいのかなと思い、コマンドプロンプト(cmd.exe)で実行してみましたが結果は変わらず。

エラーの原因

以下に原因と解決方法がありました。

Scoopはpwsh.exeを使用して、scoopが実行するPowerShellスクリプトを実行します。(scoop は 96% PowerShell です)
cmd.exeで実行しても、pwsh.exeを使用してpwshをスクープするために必要なスクリプトを実行します。
この問題は、Windows PowerShell(PowerShell 5 / powershell.exe)を使用することで解決されるため、scoopはpwshの代わりにそれを使用してPowerShellスクリプトを実行します。

対応方法

WindowsにPowerShellのバージョンが複数あってややこしいのですが、PowerShell 7(pwsh)をアップデートする際は、PowerShell 7(pwsh.exe)やコマンドプロンプト(cmd.exe)ではなく、標準でインストールされているWindows PowerShell(PowerShell 5 / powershell.exe)から実施することでエラーは発生しなくなります。

Windows PowerShellはファイル名を指定して実行で「powershell」と入力して「OK」を押すことで起動できます。
Windows PowerShell