Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Root directory of portable packages is always added to the PATH regardless of RelativeFilePath #2909

Closed
sitiom opened this issue Feb 2, 2023 · 7 comments
Labels
Area-Path Issue related to path environment variable Issue-Bug It either shouldn't be doing this or needs an investigation. Portable Issue related to portable package
Milestone

Comments

@sitiom
Copy link

sitiom commented Feb 2, 2023

Brief description of your issue

In a machine without developer mode and in a non-admin shell, Portable packages with subdirectories under RelativeFilePath are not properly added to PATH. This is because the root directory of the package is always added to the PATH regardless.

Steps to reproduce

  • Ensure developer mode is turned off and not running under an admin shell (symlinking would happen otherwise)
  • Install a package whose RelativeFilePath contains subdirectories. Let us install ffmpeg for this example: winget install ffmpeg
  • The root of the package is added to the path (%localappdata%\Microsoft\WinGet\Packages\Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3d8bbwe\) instead of the actual file path (%localappdata%\Microsoft\WinGet\Packages\Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3d8bbwe\ffmpeg-5.1.2-full_build\bin)

Expected behavior

The root directory should not be added to the path but directories relative to the RelativeFilePath (%localappdata%\Microsoft\WinGet\Packages\Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3d8bbwe\ffmpeg-5.1.2-full_build\bin).

Actual behavior

The root directory of the package is always added to the PATH regardless of the RelativeFilePath (%localappdata%\Microsoft\WinGet\Packages\Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3d8bbwe\) .

Environment

Windows Package Manager v1.4.10173
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.22621.1194
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.19.10173.0

Another question, how are command aliases handled in non-developer mode? What if there are multiple executables in one directory, and you only want to add one of them to the path?

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Triage Issue need to be triaged label Feb 2, 2023
@sitiom sitiom changed the title Root directory of portable packages are always added to the PATH regardless of RelativeFilePath Root directory of portable packages is always added to the PATH regardless of RelativeFilePath Feb 2, 2023
@stephengillie stephengillie added Issue-Bug It either shouldn't be doing this or needs an investigation. and removed Needs-Triage Issue need to be triaged labels Feb 2, 2023
@DanielHabenicht
Copy link

I can confirm this. So this basically effects all users who are not developing winget? (Best real life issue for "Works on myour machines" 😆)

On a side note:
In issue #2711 they discuss about how it is currently impossible to execute executables linked to binary (.dlls) one way to solve it is by adding the installed folder directly to the PATH.

So maybe thats a straightforward way to solve it, just add the installed dir to PATH?. (I am not familar with the project and I don't know what other implications this might have, possibly mixing up some references if the added directory contains more than the desired .exe)

@sitiom
Copy link
Author

sitiom commented Feb 5, 2023

So maybe thats a straightforward way to solve it, just add the installed dir to PATH?. (I am not familar with the project and I don't know what other implications this might have, possibly mixing up some references if the added directory contains more than the desired .exe)

That is precisely the case. You might not want other executables to be added to the PATH. But it is an option.

@DanielHabenicht
Copy link

DanielHabenicht commented Feb 5, 2023

So maybe thats a straightforward way to solve it, just add the installed dir to PATH?. (I am not familar with the project and I don't know what other implications this might have, possibly mixing up some references if the added directory contains more than the desired .exe)

That is precisely the case. You might not want other executables to be added to the PATH. But it is an option.

Maybe adding a filter/selector for files being copied to this directory could solve it? This way only files needed for the program will be copied to the Winget Package Directory.

@rlaphoenix
Copy link

This same issue is happening with aria2.aria2, in the exact same way.

@denelon denelon added this to the v1.5-Client milestone Feb 14, 2023
@denelon denelon added this to WinGet Feb 14, 2023
@denelon denelon moved this to Assigned in WinGet Feb 18, 2023
@denelon denelon added Portable Issue related to portable package Area-Path Issue related to path environment variable labels Feb 21, 2023
@denelon denelon modified the milestones: v1.5-Client, v.Next-Client Apr 19, 2023
@mdanish-kh
Copy link
Contributor

This has been fixed in WinGet v1.5.1081-preview release through PR #3002

cc @denelon

@denelon denelon closed this as completed May 1, 2023
@github-project-automation github-project-automation bot moved this from Assigned to Done in WinGet May 1, 2023
@sitiom
Copy link
Author

sitiom commented May 31, 2023

It would have been great if the fix was backported in https://github.com/microsoft/winget-cli/releases/tag/v1.4.11071

@denelon
Copy link
Contributor

denelon commented Jun 1, 2023

@sitiom we don't take servicing updates lightly. We limit those to the minimum changes necessary since GA (Generally Available) releases have such a large blast radius. We're expecting a 1.5 release candidate build very soon™️. I'd like to release 1.5 at the end of the month.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Path Issue related to path environment variable Issue-Bug It either shouldn't be doing this or needs an investigation. Portable Issue related to portable package
Projects
None yet
Development

No branches or pull requests

7 participants