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

Aberta Para iniciantes
#6,718 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 2 dias

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
79/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
cpp
Domínio
cli

Direção de pesquisa

Leia src/AppInstallerCLICore/Workflows/PortableFlow.cpp nos dois pontos de verificação de hardlinks e src/AppInstallerCLICore/PortableInstaller.cpp em SetExpectedState. Compare como os nomes do alias e do executável são tratados quando diferem apenas entre maiúsculas e minúsculas e, em seguida, execute os testes relevantes de instalação portable. O trabalho estará concluído quando a instalação de um pacote portable com um alias que difere do executável apenas entre maiúsculas e minúsculas for bem-sucedida e o alias iniciar o executável.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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

Linguagem predominante
C++
Estrelas
26.6k
Forks
1.8k
Merge médio
2d 18h
PRs com merge (30d)
42

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de microsoft/winget-cli

Todas as issues de microsoft/winget-cli

Issues semelhantes

Mais issues de C++

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.