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

Open Beginner friendly
#6,718 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
79/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp
Domain
cli

Research direction

Read src/AppInstallerCLICore/Workflows/PortableFlow.cpp at the two hardlink checks and src/AppInstallerCLICore/PortableInstaller.cpp at SetExpectedState. Compare how the alias and executable names are handled when they differ only by case, then run the relevant portable install tests. Done means installing a portable package with a case-only alias difference succeeds and the alias launches the executable.

Written by the indexing model from the issue text.

Description

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

Dominant language
C++
Stars
26.6k
Forks
1.8k
Avg merge
2d 18h
Merged PRs (30d)
42

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/winget-cli

All issues in microsoft/winget-cli

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.