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

Update available environment variables so the user does not need to restart their terminal #3077

Open
lloydjatkinson opened this issue Mar 15, 2023 · 12 comments
Labels
Area-Path Issue related to path environment variable Issue-Feature This is a feature request for the Windows Package Manager client.

Comments

@lloydjatkinson
Copy link

Description of the new feature / enhancement

Some software that is installed adds itself to the PATH environment variable. These changes are not surfaced to the current terminal session and requires the user to close the terminal and open it again. I consider this to be a huge blocker for creating fully automated software installations as the environment variables it added are often needed in the next step.

Consider NVM as per the docs here: https://learn.microsoft.com/en-us/windows/dev-environment/javascript/nodejs-on-windows

winget install --id=CoreyButler.NVMforWindows  -e

Followed by another line in the same script (again, as per the docs):

nvm install latest

Results in:

PS C:\Users\User\AppData\Roaming\nvm> nvm install latest
nvm : The term 'nvm' is not recognized as the name of a cmdlet, function, script file, or operable program.

Proposed technical implementation details

WinGet or Terminal should update the user environment variables in order to unblock automated installations of software

@lloydjatkinson lloydjatkinson added the Issue-Feature This is a feature request for the Windows Package Manager client. label Mar 15, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Triage Issue need to be triaged label Mar 15, 2023
@stephengillie stephengillie removed the Needs-Triage Issue need to be triaged label Mar 15, 2023
@Trenly
Copy link
Contributor

Trenly commented Mar 15, 2023

@stephengillie - Area-Path also

@stephengillie stephengillie added the Area-Path Issue related to path environment variable label Mar 15, 2023
@denelon

This comment was marked as outdated.

@denelon denelon marked this as a duplicate of #3067 Mar 15, 2023
@microsoft-github-policy-service

This comment was marked as outdated.

@denelon

This comment was marked as off-topic.

@denelon denelon marked this as a duplicate of #222 Mar 15, 2023
@microsoft-github-policy-service

This comment was marked as outdated.

@globdug
Copy link

globdug commented Apr 9, 2023

I had the same problem.

This solution seems to work for me.

winget install --id=CoreyButler.NVMforWindows  -e --silent

$env:NVM_HOME = [System.Environment]::GetEnvironmentVariable("NVM_HOME", "User")
$env:NVM_SYMLINK = [System.Environment]::GetEnvironmentVariable("NVM_SYMLINK", "User")
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")

nvm install 18.6.0
nvm use 18.6.0

@microsoft-github-policy-service

This comment was marked as outdated.

1 similar comment
@microsoft-github-policy-service
Copy link
Contributor

@lloydjatkinson this issue has been marked as duplicate and has not had any activity for 1 day. It will be closed for housekeeping purposes.

@Trenly
Copy link
Contributor

Trenly commented Apr 21, 2023

@denelon

@denelon denelon removed the Resolution-Duplicate Issue is a duplicate label Apr 21, 2023
@denelon denelon reopened this Apr 21, 2023
@soredake
Copy link

Totally agree that PATH should be reloaded after installing package so i can use it right away, similar feature request for chocolatey chocolatey/choco#2458

@denelon
Copy link
Contributor

denelon commented Jun 16, 2023

We're currently working on the dependency flow:

You may also want to take a look at:

We're looking at a few scenarios related to the path, and there is discussion and a possible workaround as well as some design work on how we might achieve this.

@jazzdelightsme
Copy link
Member

jazzdelightsme commented Aug 22, 2023

@lloydjatkinson, after installing the WingetPathUpdater package, this should work as expected. It requires admin to install, though.

C:\Windows\System32>where nvm
INFO: Could not find files for the given pattern(s).

C:\Windows\System32>set nvm
Environment variable nvm not defined

C:\Windows\System32>winget install WingetPathUpdater
Found WingetPathUpdater [jazzdelightsme.WingetPathUpdater] Version 1.2
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://github.com/jazzdelightsme/PowershellStub/releases/download/v1.0/PowershellStub.exe
  ██████████████████████████████  1.87 KB / 1.87 KB
Successfully verified installer hash
Starting package install...
Successfully installed

C:\Windows\System32>winget install --id=CoreyButler.NVMforWindows -e
Found NVM for Windows [CoreyButler.NVMforWindows] Version 1.1.11
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://github.com/coreybutler/nvm-windows/releases/download/1.1.11/nvm-setup.exe
  ██████████████████████████████  5.46 MB / 5.46 MB
Successfully verified installer hash
Starting package install...
Successfully installed

C:\Windows\System32>where nvm
C:\Users\AdminUser\AppData\Roaming\nvm\nvm.exe

C:\Windows\System32>set nvm
NVM_HOME=C:\Users\AdminUser\AppData\Roaming\nvm
NVM_SYMLINK=C:\Program Files\nodejs

C:\Windows\System32>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Path Issue related to path environment variable Issue-Feature This is a feature request for the Windows Package Manager client.
Projects
None yet
Development

No branches or pull requests

7 participants