winget-cli
winget-cli copied to clipboard
Installation of portable packages does not respect scope preference from settings.json
Brief description of your issue
Installation of portable packages does not respect scope preference defined in the settings.json. Explicitly using the --scope parameter works, however.
Steps to reproduce
- Add this section in your
settings.json:
"installBehavior": {
"preferences": {
"scope": "machine"
}
},
- Install a portable package without explicitly defining the scope (e.g.,
winget install yt-dlp.yt-dlp) - Package is installed under user scope
Expected behavior
It should respect the scope preference in the settings.json
Actual behavior
It defaults to the user scope despite the config in the settings.
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
Logs: %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir
User Settings: %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json
I think I found the bug.
In PortableFlow.cpp in InitializePortableInstaller(), there is the following line:
scope = Manifest::ConvertToScopeEnum(context.Args.GetArg(Execution::Args::Type::InstallScope));
This doesn't check the settings.json file at all.
To fix this, it needs to check ConvertScope(Settings::User().Get<Settings::Setting::InstallScopePreference>()) and ConvertScope(Settings::User().Get<Settings::Setting::InstallScopeRequirement>()) as well.