marticliment / UniGetUI

UniGetUI: The Graphical Interface for your package managers. Could be terribly described as a package manager manager to manage your package managers
https://www.marticliment.com/unigetui/
MIT License
10.62k stars 348 forks source link

[BUG] Installing Chocolatey MSI via winget.exe installs Chocolatey to %LOCALAPPDATA%\Programs\WingetUI\choco-cli #2380

Closed redactedscribe closed 2 weeks ago

redactedscribe commented 3 weeks ago

Please confirm these before moving forward

UniGetUI Version

3.1.0 beta 1

Windows version, edition and architecture

Windows 11 Pro

Describe your issue

I'm not sure what's happening here, but I'm attempting to install Chocolatey onto my system so that UniGetUI can use a system choco.exe. To do this, I'm using winget.exe directly via a console: winget install chocolatey which installs https://github.com/chocolatey/choco/releases/download/2.3.0/chocolatey-2.3.0.0.msi. For some reason I can't understand, this is getting installed to %LOCALAPPDATA%\Programs\WingetUI\choco-cli when the two projects Chocolatey and UniGetUI (WingetUI) are unrelated.

Because it looks like UniGetUI is somehow redirecting the Chocolatey MSI installation to install to %LOCALAPPDATA%\Programs\WingetUI\choco-cli, when re-lauching UniGetUI it does a bunch of copies from this path to the new %LOCALAPPDATA%\UniGetUI\Chocolatey path. This means even though I am trying to install Chocolatey to the system, UniGetUI is copying it to the normal bundled Chocolatey's location and using that instead.

Before installing Chocolatey, UniGetUI could not find the exe. After installation, it can, but it copies it to the bundled location and uses that, even though "Use system Chocolatey" has been enabled throughout this whole process.

I'm confused.

Steps to reproduce the issue

  1. Don't install Chocolatey when installing UniGetUI.
  2. Install Chocolatey via winget.exe winget install chocolatey.
  3. choco.exe is installed to %LOCALAPPDATA%\Programs\WingetUI\choco-cli even though I imagine it should install to some Chocolatey dir unrelated to WingetUI.
  4. Run UniGetUI and choco.exe and related files copy to the UnigetUI appdata dir.
  5. choco.exe is now found but it's not the system choco.exe since a system one was never installed by the MSI installer.

UniGetUI Log

[01/07/2024 18:24:55] Moving Bundled Chocolatey from old path to new path...
...
[01/07/2024 18:24:56] Copying C:\Users\User\AppData\Local\Programs\WingetUI\choco-cli\choco.exe
[01/07/2024 18:24:56] Copying C:\Users\User\AppData\Local\Programs\WingetUI\choco-cli\choco.exe.ignore
[01/07/2024 18:24:56] Copying C:\Users\User\AppData\Local\Programs\WingetUI\choco-cli\choco.exe.manifest
...
[01/07/2024 18:24:56] Deleting old Chocolatey directory C:\Users\User\AppData\Local\Programs\WingetUI\choco-cli
...
[01/07/2024 18:24:59] ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
                      █▀▀▀▀▀▀▀▀▀▀▀▀▀ MANAGER LOADED ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
                      █ Name: Chocolatey
                      █ Enabled: True
                      █ Found: True
                      █ Fancye exe name: choco.exe
                      █ Executable path: C:\Users\User\AppData\Local\UniGetUI\Chocolatey\bin\choco.exe
                      █ Call arguments: 
                      █ Version: 
                      █   2.3.0
                      ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

Package Managers Logs

After step 5, this is the log state:

Manager Chocolatey with version:
2.3.0

——————————————————————————————————————————

Logged subprocess-based task on manager Chocolatey. Task type is ListSources
Subprocess executable: "C:\Users\User\AppData\Local\UniGetUI\Chocolatey\bin\choco.exe"
Command-line arguments: " source list"
Process start time: 01/07/2024 18:34:09
Process end time:   01/07/2024 18:34:10

-- Process STDOUT
  Chocolatey v2.3.0
  Directory 'C:\Users\User\AppData\Local\UniGetUI\Chocolatey\bin\lib' does not exist.
  chocolatey - https://community.chocolatey.org/api/v2/ | Priority 0|Bypass Proxy - False|Self-Service - False|Admin Only - False.

Return code: SUCCESS (0)

——————————————————————————————————————————

Logged subprocess-based task on manager Chocolatey. Task type is ListUpdates
Subprocess executable: "C:\Users\User\AppData\Local\UniGetUI\Chocolatey\bin\choco.exe"
Command-line arguments: " outdated"
Process start time: 01/07/2024 18:34:13
Process end time:   01/07/2024 18:34:15

-- Process STDOUT
  Chocolatey v2.3.0
  Directory 'C:\Users\User\AppData\Local\UniGetUI\Chocolatey\bin\lib' does not exist.
  Outdated Packages
   Output is package name | current version | available version | pinned?
  Chocolatey has determined 0 package(s) are outdated. 

Return code: SUCCESS (0)

——————————————————————————————————————————

Logged subprocess-based task on manager Chocolatey. Task type is ListPackages
Subprocess executable: "C:\Users\User\AppData\Local\UniGetUI\Chocolatey\bin\choco.exe"
Command-line arguments: " list"
Process start time: 01/07/2024 18:34:13
Process end time:   01/07/2024 18:34:15

-- Process STDOUT
  Chocolatey v2.3.0
  Directory 'C:\Users\User\AppData\Local\UniGetUI\Chocolatey\bin\lib' does not exist.

Return code: SUCCESS (0)

——————————————————————————————————————————

Logged subprocess-based task on manager Chocolatey. Task type is ListSources
Subprocess executable: "C:\Users\User\AppData\Local\UniGetUI\Chocolatey\bin\choco.exe"
Command-line arguments: " source list"
Process start time: 01/07/2024 18:34:14
Process end time:   01/07/2024 18:34:17

-- Process STDOUT
  Chocolatey v2.3.0
  Directory 'C:\Users\User\AppData\Local\UniGetUI\Chocolatey\bin\lib' does not exist.
  chocolatey - https://community.chocolatey.org/api/v2/ | Priority 0|Bypass Proxy - False|Self-Service - False|Admin Only - False.

Return code: SUCCESS (0)

——————————————————————————————————————————

Relevant information

No response

Screenshots and videos

No response

marticliment commented 3 weeks ago

I suspect what can be happening here:

In order to work properly, if UniGetUI detects that chocolatey is not installed, and that the user has chocolatey enabled, it creates the required Environment Variables in order for chocolatey to work.

Therefore, when attempting to install chocolatey again, the installer picks those variables and follows them. Chocolatey gets installed on the old location.

Then, UniGetUI attempts to migrate Chocolatey to the new location (see your logs), and apparent is not updating the environment path variables accordingly, and then chocolatey is getting installed again on the old location.

I will try to fix this

redactedscribe commented 3 weeks ago

Ah, an environment variable. That makes sense. I had a look:

Variable: chocolateyinstall Value: C:\Users\User\AppData\Local\Programs\WingetUI\choco-cli

UniGetUI also adds C:\Users\User\AppData\Local\UniGetUI\Chocolatey\bin to PATH.


After removing chocolateyinstall and the UniGetUI path from PATH, winget install chocolatey installs to C:\ProgramData\chocolatey now. I will see what UniGetUI thinks of this.

Result: With Use system Chocolatey disabled, Chocolatey is not found. Enabling Use system Chocolatey now finds the system one:

[01/07/2024 20:56:01] ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
                      █▀▀▀▀▀▀▀▀▀▀▀▀▀ MANAGER LOADED ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
                      █ Name: Chocolatey
                      █ Enabled: True
                      █ Found: True
                      █ Fancye exe name: choco.exe
                      █ Executable path: C:\ProgramData\chocolatey\bin\choco.exe
                      █ Call arguments: 
                      █ Version: 
                      █   2.3.0
                      ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

Thanks @marticliment.

marticliment commented 3 weeks ago

UniGetUI also adds C:\Users\User\AppData\Local\UniGetUI\Chocolatey\bin to PATH

This is expected. Perhaps I need to add the chocolateyinstall variable to the chocolatey migrator