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

Reload PATH environment variable after package installation #531

Closed
kimwalisch opened this issue Aug 5, 2020 · 7 comments
Closed

Reload PATH environment variable after package installation #531

kimwalisch opened this issue Aug 5, 2020 · 7 comments
Labels
Issue-Feature This is a feature request for the Windows Package Manager client. Resolution-Duplicate Issue is a duplicate
Milestone

Comments

@kimwalisch
Copy link

Hi,

My Primesieve package is a command-line tool and its setup (based on Inno Setup) adds its path (C:\Program Files\Primesieve\bin) to the PATH environment variable. However when I install primesieve using winget install primesieve I cannot immediately use it on the command-line as the PATH environment variable has not been reloaded yet (tested using cmd.exe):

path-issue

So I need to close the current terminal window, open a new terminal window and then I can start using my tool. This is quite annoying, on Linux and MacOS you can immediately use a tool after the installation with the package manager has completed.

Is there a known workaround for this issue?

If there is no workaround for this issue yet, I see 2 possible options to fix/improve this issue:

  1. Reload the PATH environment variable after each package installation.
  2. Add a yaml manifest option where package maintainers can specify if the PATH environment variable should be reloaded after the package installation.
@denelon denelon transferred this issue from microsoft/winget-pkgs Aug 10, 2020
@ghost ghost added the Needs-Triage Issue need to be triaged label Aug 10, 2020
@denelon
Copy link
Contributor

denelon commented Aug 10, 2020

Related to #194 in the sense that we may need to handle PATH reload for that as well.

@denelon denelon added Issue-Feature This is a feature request for the Windows Package Manager client. and removed Needs-Triage Issue need to be triaged labels Aug 10, 2020
@denelon denelon added this to the Package Manager Backlog milestone Aug 10, 2020
@sredna
Copy link
Contributor

sredna commented Aug 20, 2020

There is a Windows broadcast message you can send to tell all running apps that they should reload their environment but Explorer.exe is the only application (AFAIK) that actually cares enough to do it (and it probably uses a undocumented function to do so). Even if most applications did it, cmd.exe would probably be excluded from it by design, you don't want your command interpreter to automatically override your variables at unknown times.

The only documented way for this to actually work would be for winget to exist as a batch file and as wingetReal.exe finishes, it would have to write set .. statements into a batch file that the main batch file runs and this would update the parent cmd.exe instance. There are however disadvantages to using a batch file as your main entry-point.

Changing the environment of your parent process by modifying the PEB is undocumented, has multiple race conditions and is probably too much of a hack.

@kiran94
Copy link

kiran94 commented Sep 2, 2020

Adding that chocolatey ships with a script called refreshenv , I currently use this to refresh my environment variables including PATH if I don't want to re-open terminal.

@ArtexJay
Copy link

i think this would be really cool if powershell would then be able to automatically set the path to any installed applications, allowing users to easily open programs like you can do with notepad at the moment.

@denelon denelon modified the milestones: Backlog - Windows Package Manager, v.Next - Windows Package Manager May 4, 2021
@kimwalisch
Copy link
Author

This issue is basically identical to issue #222 (and many other similar issues that have already been closed as duplicate).

@denelon
Copy link
Contributor

denelon commented Jul 12, 2021

Duplicate of #222

@denelon denelon marked this as a duplicate of #222 Jul 12, 2021
@ghost
Copy link

ghost commented Jul 12, 2021

@kimwalisch we've identified this Issue as a duplicate of another one that already exists. This specific instance is being closed in favor of tracking the concern over on the referenced Issue. Thanks for your report! Be sure to add your 👍 to the other issue to help raise the priority.

@ghost ghost closed this as completed Jul 12, 2021
@ghost ghost added the Resolution-Duplicate Issue is a duplicate label Jul 12, 2021
@denelon denelon modified the milestones: v.Next-Client, v1.2 Client, v1.1-Client Oct 1, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Feature This is a feature request for the Windows Package Manager client. Resolution-Duplicate Issue is a duplicate
Projects
None yet
Development

No branches or pull requests

5 participants