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

[Package Issue]: Python.Python override causes installer to ignore scope #153928

Closed
2 tasks done
github-account1111 opened this issue May 16, 2024 · 8 comments
Closed
2 tasks done
Labels
Needs-Author-Feedback This needs a response from the author. No-Recent-Activity No activity has occurred on this work item for seven days.

Comments

@github-account1111
Copy link

Please confirm these before moving forward

  • I have searched for my issue and not found a work-in-progress/duplicate/resolved issue.
  • I have not been informed if the issue is resolved in a preview version of the winget client.

Category of the issue

Installation issue.

Brief description of your issue

Using overrides makes it impossible to install Python system-wide.

Steps to reproduce

winget install --id Python.Python.3.11 --scope machine --override '/quiet'

Actual behavior

Python is installed in %LOCALAPPDATA%\Programs.

Expected behavior

Python is installed in %PROGRAMFILES% .

Environment

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

Windows: Windows.Desktop v10.0.19045.4412
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.22.11261.0

Winget Directories
-------------------------------------------------------------------------------------------------------------------------------
Logs                               %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir
User Settings                      %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json
Portable Links Directory (User)    %LOCALAPPDATA%\Microsoft\WinGet\Links
Portable Links Directory (Machine) C:\Program Files\WinGet\Links
Portable Package Root (User)       %LOCALAPPDATA%\Microsoft\WinGet\Packages
Portable Package Root              C:\Program Files\WinGet\Packages
Portable Package Root (x86)        C:\Program Files (x86)\WinGet\Packages
Installer Downloads                %USERPROFILE%\Downloads

Links
---------------------------------------------------------------------------
Privacy Statement   https://aka.ms/winget-privacy
License Agreement   https://aka.ms/winget-license
Third Party Notices https://aka.ms/winget-3rdPartyNotice
Homepage            https://aka.ms/winget
Windows Store Terms https://www.microsoft.com/en-us/storedocs/terms-of-sale

Admin Setting                             State
--------------------------------------------------
LocalManifestFiles                        Disabled
BypassCertificatePinningForMicrosoftStore Disabled
InstallerHashOverride                     Disabled
LocalArchiveMalwareScanOverride           Disabled

Screenshots and Logs

No response

@github-account1111 github-account1111 added the Issue-Bug It either shouldn't be doing this or needs an investigation. label May 16, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Triage This work item needs to be triaged by a member of the core team. label May 16, 2024
@SpecterShell
Copy link
Contributor

SpecterShell commented May 17, 2024

The scope is controlled by the InstallAllUsers switch from the installer, which would be overrode by your own installer switches by using the --override switch from WinGet.

- Architecture: x86
Scope: machine
InstallerUrl: https://www.python.org/ftp/python/3.11.9/python-3.11.9.exe
InstallerSha256: AF19E5E2F03E715A822181F2CB7D4EFEF4EDA13FA4A2DB6DA12E998E46F5CBF9
InstallerSwitches:
InstallLocation: DefaultAllUsersTargetDir=<INSTALLPATH>
Custom: InstallAllUsers=1 PrependPath=1

It is recommended to use the --silent switch from WinGet for silent (without progress) installation.

@github-account1111
Copy link
Author

github-account1111 commented May 17, 2024

\quiet was just for a minimum reproducible example. The full command is as follows:

/quiet AssociateFiles=0 CompileAll=0 PrependPath=1 Shortcuts=1 Include_doc=0 Include_debug=0 Include_dev=0 Include_exe=0 Include_launcher=0 Include_lib=1 Include_pip=1 Include_symbols=0 Include_tcltk=0 Include_test=0 Include_tools=0'

--silent alone simply isn't enough. What is the reason it is recommended?

Also, am I understanding correctly that simply using the --override switch negates the --scope switch entirely, even though I am not using any overrides that conflict with scope?

@SpecterShell
Copy link
Contributor

SpecterShell commented May 17, 2024

Sorry, I thought you were looking for a way to install it silently.

Take the x86 installer as an example. The --scope switch chooses which entry to use between the following two entries, the user one and the machine one:

Installers:
- Architecture: x86
Scope: user
InstallerUrl: https://www.python.org/ftp/python/3.11.9/python-3.11.9.exe
InstallerSha256: AF19E5E2F03E715A822181F2CB7D4EFEF4EDA13FA4A2DB6DA12E998E46F5CBF9
InstallerSwitches:
InstallLocation: DefaultJustForMeTargetDir=<INSTALLPATH>
Custom: InstallAllUsers=0 PrependPath=1
ProductCode: '{b047d2a0-fe22-4d51-ae4c-4fc15fb14b31}'
AppsAndFeaturesEntries:
- DisplayName: Python 3.11.9 (32-bit)
DisplayVersion: 3.11.9150.0
ProductCode: '{b047d2a0-fe22-4d51-ae4c-4fc15fb14b31}'
UpgradeCode: '{C2007350-35A9-53B8-9AC1-4EB4C04802E2}'
- Architecture: x86
Scope: machine
InstallerUrl: https://www.python.org/ftp/python/3.11.9/python-3.11.9.exe
InstallerSha256: AF19E5E2F03E715A822181F2CB7D4EFEF4EDA13FA4A2DB6DA12E998E46F5CBF9
InstallerSwitches:
InstallLocation: DefaultAllUsersTargetDir=<INSTALLPATH>
Custom: InstallAllUsers=1 PrependPath=1
ProductCode: '{b047d2a0-fe22-4d51-ae4c-4fc15fb14b31}'
AppsAndFeaturesEntries:
- DisplayName: Python 3.11.9 (32-bit)
DisplayVersion: 3.11.9150.0
ProductCode: '{b047d2a0-fe22-4d51-ae4c-4fc15fb14b31}'
UpgradeCode: '{C2007350-35A9-53B8-9AC1-4EB4C04802E2}'
ElevationRequirement: elevatesSelf

If one would like to install it in machine scope by specifying --scope machine, WinGet will choose the second one and apply the installer switches described in this entry, including the one InstallAllUsers=1 which asks the installer to install machine-wide. And if the --override WinGet switch is used, all these installer switches will be discarded.

@github-account1111
Copy link
Author

github-account1111 commented May 17, 2024

No I should be sorry, I wasn't clear in explaining my intent in the initial example.

Thanks very much for the explanation, this makes much more sense now. Is there a technical reason winget discards Custom switches when --overrides is used? Can't they be appended? At the very least, a dialog before proceeding with the install informing the user that the --scope machine part of the install command will be discarded would be helpful.

@SpecterShell
Copy link
Contributor

No I should be sorry, I wasn't clear in explaining my intent in the initial example.

Thanks very much for the explanation, this makes much more sense now. Is there a technical reason winget discards Custom switches when --overrides is used? Can't they be appended? At the very least, a dialog before proceeding with the install informing the user that the --scope machine part of the install command will be discarded would be helpful.

It not only discards the Custom switch, but also all other switches, including the InstallLocation switch above, the pre-defined Silent switch (/quiet /norestart in this case), the pre-defined SilentWithProgress switch (/passive /norestart) and the pre-defined Log switch (/log "<LOGPATH>"). All of them will be overrode by --override.

The --custom WinGet switch will only override the custom switch. Since this switch has already been used for forcing the scope for the installer and will be overrode by --custom, you need to manually include InstallAllUsers=1 in your switches.

So the final command line would be like

winget install --id Python.Python.3.11 --scope machine --silent --custom 'InstallAllUsers=1 AssociateFiles=0 CompileAll=0 PrependPath=1 Shortcuts=1 Include_doc=0 Include_debug=0 Include_dev=0 Include_exe=0 Include_launcher=0 Include_lib=1 Include_pip=1 Include_symbols=0 Include_tcltk=0 Include_test=0 Include_tools=0' 

@Trenly
Copy link
Contributor

Trenly commented May 17, 2024

The --custom WinGet switch will only override the custom switch.

Actually, it doesn't! --custom will only append the value

2024-05-17 10:07:01.168 [CLI ] WinGet invoked with arguments: 'install' '-m' 'C:\Users\WDAGUtilityAccount\Desktop\SandboxTest\3.12.3' '--verbose-logs' '--ignore-local-archive-malware-scan' '--dependency-source' 'winget' '--custom' '/quiet'
|
| Truncated for readability
|
2024-05-17 10:07:04.732 [CLI ] Starting: 'C:\Users\WDAGUtilityAccount\AppData\Local\Temp\WinGet\Python.Python.3.12.3.12.3\python-3.12.3-amd64.exe' with arguments '/passive /norestart /log "C:\Users\WDAGUtilityAccount\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir\WinGet-Python.Python.3.12.3.12.3-2024-05-17-10-07-04.731.log" InstallAllUsers=0 PrependPath=1 /quiet'

@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs-Triage This work item needs to be triaged by a member of the core team. label May 17, 2024
@Trenly
Copy link
Contributor

Trenly commented May 17, 2024

@github-account1111 - try using --custom instead of --override to add parameters to the install without erasing any of the ones defined in the manifest

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Author-Feedback This needs a response from the author. No-Recent-Activity No activity has occurred on this work item for seven days. and removed Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Author-Feedback This needs a response from the author. labels May 17, 2024
Copy link
Contributor

Hello @github-account1111,

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any recent activity. It will be closed if no further activity occurs within 3 days of this comment.

Template: msftbot/noRecentActivity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Author-Feedback This needs a response from the author. No-Recent-Activity No activity has occurred on this work item for seven days.
Projects
None yet
Development

No branches or pull requests

3 participants