How to fix “The term ‘winget’ is not recognized as a name of a cmdlet, function, script file, or executable program.” in Windows?

3 min read.

This article explains how I fixed Terminal / PowerShell being unable to locate my winget when I was trying to install something with it. This was quite unexpected as I knew for sure I had installed winget, and I had also used it before successfully.

But alas, things break down and need fixing. And here’s how to fix this particular issue.

Problem

Let’s take a quick look at the actual problem first. Imagine this: You’re trying to install or update something using winget using PowerShell, Terminal, command line, bash or some other flavor of a command-line interpreter, but you run into this error:

winget: The term 'winget' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

If that’s the exact error you’re getting, chances are the reason is quite simple. You either don’t have winget, or your flavor of command-line interpreter doesn’t know how to find the executable winget.exe.

Reason

For whatever reason, winget installs without modifying the Path environment variable to include the, well, path to the winget executable. Or at least it might.

And while it MIGHT actually add the path to the executable, that path might be version-specific – and after winget getting updated itself, that path changes. And you won’t have winget anymore.

Ah well. A lot of weird things have happened to MY winget installation for sure. But let’s take a look at the couple of different ways how to fix it.

Solution

Time needed: 10 minutes

How to fix “The term ‘winget’ is not recognized as a name of a cmdlet, function, script file, or executable program.” in Windows 10?

  1. Verify winget alias is enabled

    This was a funny one – didn’t even know this could be broken!

    Verify that “winget” alias is enabled for use in different Windows apps. Do this by searching for “Manage app execution aliases” in Start menu:



    Then make sure winget is enabled:


    And here’s a demonstration on how this affects Windows Terminal – 2 first tries the alias was turned off, for the last one it was enabled:


  2. Add all Windows Apps to your PATH at once

    Add this to your environment variable “PATH” – or make sure that it is there already.

    %UserProfile%\AppData\Local\Microsoft\WindowsApps.

    This is kind of a no-brainer – even if you don’t have winget installed, this should probably be set up. Might fix some other apps that you didn’t yet know were broken.

    That said…

  3. Install or update your winget

    Okay, this might sound stupid, but it might make sense to double-check you have installed winget in the first place. While having a command-line interface to Microsoft Store really does make sense (not only for automation use cases, but also for being able to actually install something whenever the Microsoft Store UI is broken again as it sometimes is), I don’t think it is automatically installed with Windows out-of-the-box.

    You can make sure you have the latest version of winget installed by searching for “winget” or “App Installer” in Microsoft Store, if you’re crazy enough to try and use it.

    I’m sure it’ll load any moment now. Any moment now.

    If you get tired of waiting for Microsoft Store to load, check out the next step.

  4. Install or reinstall winget

    If you don’t have 4 hours to wait for the Store to load, you might want to download the latest file from the apps GitHub repository instead.

    That would be here: https://github.com/microsoft/winget-cli/releases

    After downloading the appropriate latest version of the “App Installer” installer, reinstall it. You’ll see something like below, but that’s to be expected:

mm
5 1 vote
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments