winget-cli icon indicating copy to clipboard operation
winget-cli copied to clipboard

Commands should be available to the console after install

Open tbalasavage opened this issue 5 years ago • 13 comments

Brief description of your issue

I've installed the GitHub CLI and then attempt to run it but it fails each time. image

Steps to reproduce

winget install github.cli gh

Expected behavior

gh brings up GitHub CLI info.

Actual behavior

An error is produced

Environment

image

Any other software? No

tbalasavage avatar May 19 '20 22:05 tbalasavage

For some reason, it looks like gh isn't available directly in the PATH. It worked for me when I opened a new powershell window.

utybo avatar May 19 '20 22:05 utybo

This is likely do to the session needing reloaded. Basically, it added it, but your current PS session doesn't know about it yet. This is normal (same thing happens in all *nix shells).

That being said, it would be nice if winget automatically refreshed the path. Maybe a flag could be added to the manifest file to trigger this.

Another option would be to provided a command like winget session refresh. This is what Chocolatey does (Update-SessionEnvironment or refreshenv)

dhrrgn avatar May 20 '20 01:05 dhrrgn

@dhrrgn I think that you're correct because when I opened a new PS Core shell today, it worked as expected. I was confused yesterday because I opened a new tab in Windows Terminal after installation and received the same error message. When I opened a new and independent PS Core shell, it worked as expected today.

Regarding what you said about *nix above, if I use dnf or apt to install an application, the application is available for immediate use and doesn't require a new window. Are they doing something akin to what you suggest above?

tbalasavage avatar May 20 '20 18:05 tbalasavage

@dhrrgn is correct, we don't currently reload the session. I'm going to change the title to indicate the feature request.

JohnMcPMS avatar May 20 '20 22:05 JohnMcPMS

I ran into a similar problem when trying to install python: winget install python

After the Python installation wizard launched and finished, the tool reported: Successfully installed. But python was not automatically added to my path (reloading the session didn't help here, running $ python in the terminal takes me to the "Get Python" page in the Microsoft Store), though the python.exe was installed to the following location:

C:\Users\<username>\AppData\Local\Programs\Python\Python38

Am I missing a switch when running the install command above?

dmoncada avatar May 21 '20 00:05 dmoncada

Regarding what you said about *nix above, if I use dnf or apt to install an application, the application is available for immediate use and doesn't require a new window. Are they doing something akin to what you suggest above?

I'd imagine that's because they are adding symlinks to a location already on the PATH, such as /usr/local/bin, so there is no need to update the PATH.

mjcheetham avatar May 21 '20 08:05 mjcheetham

Actually, I have installed vim, meld and a few other applications and rebooted my computer but still the commands are not available.

nmat avatar May 21 '20 16:05 nmat

Related https://github.com/microsoft/winget-cli/issues/361

trallnag avatar Nov 03 '21 10:11 trallnag

After the Python installation wizard launched and finished, the tool reported: Successfully installed. But python was not automatically added to my path (reloading the session didn't help here, running $ python in the terminal takes me to the "Get Python" page in the Microsoft Store), though the python.exe was installed to the following location:

~~This is now a year later and it looks like winget install <python> is still broken. Am I missing a workaround? Do I need to open a ticket to the maintainers/repo of the Python package?~~

Reinstalling with the latest Python package (now 3.10) seems to get everything into PATH as expected! Not sure if the fix was within winget or within the Python package itself, but I am grateful for the fix regardless! For reference, I ran winget install Python.Python.3.

aaronsteers avatar Nov 25 '21 02:11 aaronsteers

I have the same problem with GnuWin32.make. Successfully installation but it will not add make to the path automatically. It is seen in the list so it was installed. Is this now a thing, that needs to be changed in winget or in make itself to make this happen?

Chris2011 avatar Dec 01 '21 21:12 Chris2011

@chris2011 - While I can't give a definitive answer on this (I'm not a contributor or maintainer), I do think signs point to this being the responsibility of the package itself. So I think the action would be to go to the package maintainer and see about updating the install script for this package.

aaronsteers avatar Dec 01 '21 21:12 aaronsteers

@aaronsteers ok, thx for your opinion :).

Chris2011 avatar Dec 01 '21 21:12 Chris2011

So I think the action would be to go to the package maintainer and see about updating the install script for this package.

Anyone know if there's an easy way to do this in a WiX installer?

nibanks avatar Nov 04 '22 19:11 nibanks

This package may help:

winget install WingetPathUpdater
winget install github.cli
gh # <-- works!

It works by adding winget.cmd and winget.ps1 wrapper scripts, which handle updating the PATH for you.

See also: https://github.com/jazzdelightsme/WingetPathUpdater

jazzdelightsme avatar Aug 11 '23 21:08 jazzdelightsme