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
13.41k stars 460 forks source link

[BUG] Environment variables are not updated unless WingetUI is restarted #1846

Closed Wallby closed 3 months ago

Wallby commented 9 months ago

Please confirm these before moving forward

Describe your issue

With WingetUI running, I added the environment variablers RUSTUP_HOME and CARGO_HOME, and then I tried to install Rustlang.Rustup interactively.

This installer opens a cmd.exe window and outputs the paths used. I tried to cancel and then restart the installation, but this didn't work. The only way for the new environment variables to be detected was to close WingetUI entirely and then restart it.

Steps to reproduce the issue

  1. open WingetUI
  2. go to "Edit the system environment variables"
  3. add RUSTUP_HOME and CARGO_HOME and set each to a value different than then default
  4. try to interactively install Rustlang.Rustup from WingetUI, and now after Rustup metadata and toolchains will be installed into the Rustup home directory, located at: there was the default value
  5. restart WingetUI
  6. try to interactively install Rustlang.Rustup from WingetUI again, and now after Rustup metadata and toolchains will be installed into the Rustup home directory, located at: there was the new value

WingetUI Log

Doesn't seem applicable

Package Managers Logs

Doesn't seem applicable

Relevant information

Tested using WingetUI 2.2.0 (i.e. the latest stable release) on Windows 10.

Screenshots and videos

No response

marticliment commented 9 months ago

Hello,

I am afraid that this is an issue that cannot be fixed due to the way in which Windows works. Each process (and their children) have their immutable env variables at launch, and they are not updated until the program is restarted. I am afraid that this is not a but with WingetUI, but rather an issue with how Windows handles env variables

Wallby commented 9 months ago

@marticliment

I am afraid that this is an issue that cannot be fixed due to the way in which Windows works. Each process (and their children) have their immutable env variables at launch, and they are not updated until the program is restarted. I am afraid that this is not a but with WingetUI, but rather an issue with how Windows handles env variables

I read here that explorer.exe will send (i.e. HWND_BROADCAST) a WM_SETTINGCHANGE to all windows if an environment variable was modified.. https://serverfault.com/a/8856

After the changes are saved, Explorer broadcasts a WM_SETTINGCHANGE message to all windows to inform them of the change. Any programs spawned via Explorer after this should get the updated environment, although already-running programs will not, unless they handle the setting change message.

marticliment commented 9 months ago

I will explore this