microsoft / winget-cli

WinGet is the Windows Package Manager. This project includes a CLI (Command Line Interface), PowerShell modules, and a COM (Component Object Model) API (Application Programming Interface).
https://learn.microsoft.com/windows/package-manager/
MIT License
22.96k stars 1.43k forks source link

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

Open lloydjatkinson opened 1 year ago

lloydjatkinson commented 1 year ago

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

Trenly commented 1 year ago

@stephengillie - Area-Path also

denelon commented 1 year ago

Duplicate of #3067

microsoft-github-policy-service[bot] commented 1 year ago

@lloydjatkinson 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.

denelon commented 1 year ago

Duplicate of #222

microsoft-github-policy-service[bot] commented 1 year ago

@lloydjatkinson 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.

globdug commented 1 year ago

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[bot] commented 1 year ago

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

microsoft-github-policy-service[bot] commented 1 year ago

@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 commented 1 year ago

@denelon

soredake commented 1 year ago

Totally agree that PATH should be reloaded after installing package so i can use it right away, similar feature request for chocolatey https://github.com/chocolatey/choco/issues/2458

denelon commented 1 year ago

We're currently working on the dependency flow:

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 commented 1 year ago

@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>