hack のためのネタ帳, etc,,,

状況

Windows 10 で winget から source が winget の Windows Terminal を入れようとしたのだが、以下のようにインストーラーが見つからないと言われて入らない。
> winget install Microsoft.WindowsTerminal
該当するインストーラーが見つかりません。詳細については、ログを参照してください。
とりあえず、--log a.txt とか付けてみるが、ログ出力してくれない。

パッケージ詳細を確認してみると以下の通り。
> winget show Microsoft.WindowsTerminal
見つかりました Windows Terminal [Microsoft.WindowsTerminal]
バージョン: 1.12.10983.0
公開元: Microsoft
発行元 URL: https://www.microsoft.com/
発行元のサポート URL: https://github.com/microsoft/terminal/issues
作成者: Microsoft
モニカー: terminal
説明: 新しい Windows ターミナル、Windows のタブ付きコマンド ライン エクスペリエンス。
ホーム ページ: https://docs.microsoft.com/windows/terminal/
ライセンス: MIT
ライセンス URL: https://github.com/microsoft/terminal/blob/master/LICENSE
プライバシー URL: https://privacy.microsoft.com/
著作権: Copyright (c) Microsoft Corporation. All rights reserved.
著作権 URL: https://github.com/microsoft/terminal/blob/master/LICENSE
リリース ノート: Changes
• The refreshed Windows 11 UI from the 1.13 preview builds is now available in 1.12!

Bug Fixes
Appearance
• Our Maximize/Restore button is now a fine round boi

Accessibility
• The profile list in the Settings UI now offers tooltips for long profile names
• We'll automatically focus the window renamer textbox when it opens
• High contrast will no longer result in a ridiculous and bad titlebar color
• When you delete a color scheme, we'll move focus back to the color scheme list
• When you delete a profile, we will re-focus the delete button automatically
• Two instances of huge debug log spam with a screen reader connected have been stamped out

Usability
• We've added some text to the color schemes page indicating that it is for editing--not setting--color schemes
  • We're working to refine how color schemes are set and edited, so stay tuned for future improvements!
• The retro terminal effect (as well as other shaders) will now work on pre-D3D11 hardware!
• Terminal will once again render properly when you move between different-DPI displays
• Resizing the window while a background color or underline is displayed will no longer smear it across the whole screen plus a fix for a huge crash that PR introduced
• It took us three releases to get it right, but we've finally solved the issue where we'd punch a hole straight through the Terminal when a dialog appeared

Reliability
• Typing an invalid background image path into the Settings UI will no longer send Terminal to a farm upstate
• There was an issue on Windows 11 where Terminal would queue up billions of animations while the screen was off; it will now no longer do so
• We've fixed crashes in ProposeCommandline, Monarch::_GetPID and other parts of WT's RPC infrastructure
• On Windows 10, the settings UI will no longer sometimes crash on close (we've updated to a new build of WinUI 2 for the fix!)

Miscellaneous
• Windows will no longer reject certain Terminal updates/reinstalls due to "differing package content"
• Fragments can once again override the names of generated profiles
• An issue from the 1073 series, where you could not upgrade the bundle using DISM, has been resolved
  • As a result, our bundle version is now over three thousand!
• @dmezh contributed some wording changes to the text about transparency/opacity
リリース ノート URL: https://github.com/microsoft/terminal/releases/v1.12.10982.0/
インストーラー:
  該当するインストーラーが見つかりません。詳細については、ログを参照してください。
見ての通りなぜかインストーラーが見つからないと言われる。

リリースノート を見てみるとバイナリーとして
  • Microsoft.WindowsTerminal_Win10_1.12.10982.0_8wekyb3d8bbwe.msixbundle
  • Microsoft.WindowsTerminal_Win11_1.12.10983.0_8wekyb3d8bbwe.msixbundle
の二つが提供されてて、1.12.10983.0 は Win11 以降専用、1.12.10982.0 は Win10 も OK 的な雰囲気が。

Windows Terminal のバージョン確認してみると以下の通り
> winget show Microsoft.WindowsTerminal --versions
見つかりました Windows Terminal [Microsoft.WindowsTerminal]
バージョン
------------
1.12.10983.0
1.12.10982.0
1.12.10733.0
1.12.10732.0
1.12.10393.0
1.12.10334.0
1.11.3471.0
1.11.2921.0
1.10.2714.0
1.10.2383.0
1.9.1942.0
1.8.1444.0
1.7.1033.0
1.6.10571.0
1.5.10411.0
1.5.10271.0
1.4.3243.0
1.4.3141.0
1.3.2651.0
1.2.2381.0
1.1.2233.0
1.1.2021.0
1.0.1811.0
1.0.1401.0
0.11.1333.0
0.11.1251.0

winget source の構造について で調べて、Manifest を確認してみたところ となっており、
それぞれ MinimumOSVersion が 10.0.18362.0、10.0.22000.0 みたいになっていた。

これは、winget-pkgs に収録されている各バージョンの manifest がバージョン毎に 1 ファイルに結合されたもの。
因みに手元の Windows 10 のバージョンは
> VER
Microsoft Windows [Version 10.0.19044.1706]
どうもこれが原因で最新版の 1.12.10983.0 を入れようとした際に、対応バイナリがなくて失敗するらしい。

winget はなんで、フォールバックして、MinimumOSVersion に適合する一つ古いの入れてくれないの?
と思うけど、多分、winget-cli の仕様なので、仕様に合わせて manifest に MinimumOSVersion: 10.0.18362.0 用の Microsoft.WindowsTerminal_Win10_1.12.10982.0_8wekyb3d8bbwe.msixbundle 入れてくれてない winget-pkgs の書き方が悪いという気も。

解法

とりあえず、根本的な問題は winget-cli か winget-pkgs が修正してくれないとどうにもならないので、
間に合わせ的に PowerShell で最新版からフォールバックするようにしてみたのが以下。
winget show Microsoft.WindowsTerminal --versions|select -Skip 4|sort -Descending {[Version]$_}|select -First 2|% {echo $_; winget install Microsoft.WindowsTerminal --version $_ ; if($?){break}}
実行結果
> winget show Microsoft.WindowsTerminal --versions|select -Skip 4|sort -Descending {[Version]$_}|select -First 2|% {echo $_; winget install Microsoft.WindowsTerminal --version $_ ; if($?){break}}
1.12.10983.0
該当するインストーラーが見つかりません。詳細については、ログを参照してください。
1.12.10982.0
見つかりました Windows Terminal [Microsoft.WindowsTerminal] バージョン 1.12.10982.0
このアプリケーションは所有者からライセンス供与されます。
Microsoft はサードパーティのパッケージに対して責任を負わず、ライセンスも付与しません。
インストーラーハッシュが正常に検証されました
パッケージのインストールを開始しています...
  ██████████████████████████████  1%
正常にインストールされました。アップグレードを完了するには、アプリケーションを再起動してください。

一般化

powershell.exe コマンド用
powershell.exe -C '&{$pkg=$Args[0];$n=$Args[1];winget show $pkg --versions|select -Skip 4|sort -Descending {[Version]$_}|select -First $n|% {echo $_;winget install $pkg --version $_;if($?){break}}}' Microsoft.WindowsTerminal 5

とりあえず、この書き方なら PowerShell 及び WSL から行ける。
cmd.exe は駄目だけど、こいつは切り捨てでいいかな?

関数化
function winget_install_n($pkg,$n){winget show $pkg --versions|select -Skip 4|sort -Descending {[Version]$_}|select -First $n|% {echo $_;winget install $pkg --version $_;if($?){break}}}

winget_install_n Microsoft.WindowsTerminal 5
インデントして整形
function winget_install_n($pkg, $n){
  winget show $pkg --versions `
  | select -Skip 4 | sort -Descending { [Version] $_ } | select -First $n `
  |% {
    echo $_
    winget install $pkg --version $_
    if($?){break}
  }
}

winget_install_n Microsoft.WindowsTerminal 5

コメントをかく


「http://」を含む投稿は禁止されています。

利用規約をご確認のうえご記入下さい

Wiki内検索

フリーエリア

管理人/副管理人のみ編集できます