Portable install deletes the executable when PortableCommandAlias differs from the file name only by case

未關閉 適合新手
#6,718 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 2 天內回覆

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
79/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
cpp
領域
cli

研究方向

閱讀 src/AppInstallerCLICore/Workflows/PortableFlow.cpp 中的兩個硬連結檢查處,以及 src/AppInstallerCLICore/PortableInstaller.cpp 中的 SetExpectedState。比較別名和可執行檔名稱僅大小寫不同時的處理方式,接著執行相關的 portable 安裝測試。當安裝一個別名僅與可執行檔名稱大小寫不同的 portable 套件成功,且該別名能啟動可執行檔時,即表示完成。

由索引模型根據 Issue 內容生成。

描述

Command-Install Needs-Triage
Relevant area(s)

WinGet CLI

Relevant command(s)

winget install

Brief description of your issue

Since hardlink aliases arrived in #6308, a zip portable fails to install when PortableCommandAlias matches the nested executable's name except for case. Blinue.Magpie 0.13.0 has RelativeFilePath: Magpie.exe and PortableCommandAlias: magpie (microsoft/winget-pkgs#490991).

PortableFlow.cpp creates a hardlink when commandAlias != originalFilename (line 255, and the same check on line 298 for single-file portables). std::filesystem::path compares case-sensitively, so magpie.exe and Magpie.exe count as different names. On NTFS they are the same file. The install removes the "existing hardlink" magpie.exe, which deletes Magpie.exe, and then create_hard_link and the copy fallback both fail. PortableInstaller::SetExpectedState makes the same comparison (line 595).

The failed install also leaves the package folder behind with only the portable index .db in it.

Steps to reproduce

winget install --source winget --id Blinue.Magpie --exact --scope user

Expected behavior

Magpie installs and magpie starts it.

Actual behavior
copy_file: The system cannot find the file specified.: "...\Blinue.Magpie_Microsoft.Winget.Source_8wekyb3d8bbwe\Magpie.exe", "...\magpie.exe"
Portable install failed; Cleaning up...

From the log:

[CORE] Removing existing portable hardlink at: ...\magpie.exe
[CORE] Creating hardlink at: ...\magpie.exe pointing to: ...\Magpie.exe
[CORE] Hardlink not supported or creation failed: create_hard_link: The system cannot find the file specified.
[CORE] Hardlink creation failed, falling back to copy: ...\magpie.exe
[CLI ] Caught std::exception: copy_file: The system cannot find the file specified.
[CLI ] Terminating context: 0x8a150057 at ...\PortableFlow.cpp:165

The same manifest without the alias installs and runs fine (tested with winget install --manifest), so I sent that as a workaround in microsoft/winget-pkgs#491068. A fix here would be to compare the alias and the file name case-insensitively at all three spots, so a case-only difference skips the hardlink.

Environment

Windows Package Manager v1.30.310
Windows 11 Pro 25H2 (10.0.26200), x64

主要語言
C++
星號
26.6k
分支
1.8k
平均合併
2 天 18 小時
30 天內合併 PR
42

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

microsoft/winget-cli 的其他 Issue

查看 microsoft/winget-cli 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。