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

Offen Anfängerfreundlich
#6,718 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 2 Tagen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
79/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
cpp
Bereich
cli

Rechercherichtung

Lies src/AppInstallerCLICore/Workflows/PortableFlow.cpp bei den beiden Hardlink-Prüfungen und src/AppInstallerCLICore/PortableInstaller.cpp bei SetExpectedState. Vergleiche, wie der Alias- und der ausführbare Dateiname behandelt werden, wenn sie sich nur durch Groß- und Kleinschreibung unterscheiden, und führe anschließend die relevanten Tests für portable Installationen aus. Als abgeschlossen gilt die Aufgabe, wenn die Installation eines portablen Pakets mit einem Alias, der sich nur durch Groß- und Kleinschreibung unterscheidet, erfolgreich ist und der Alias die ausführbare Datei startet.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

Vorherrschende Sprache
C++
Sterne
26.6k
Forks
1.8k
Ø Merge
2 T. 18 Std.
Gemergte PRs (30 T.)
42

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus microsoft/winget-cli

Alle Issues in microsoft/winget-cli

Ähnliche Issues

Weitere Issues zu C++

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.