Skip to content

Windows is not able to recongnise gh as a command ( or as a executable gh.exe ) #4772

Closed

Description

@Advik-B

Describe the bug

When i run the command gh --version it is showing me:

'gh' is not recognized as an internal or external command,
operable program or batch file.

Steps to reproduce the behaviour

  1. make sure you are NOT the local admin on the Windows PC
  2. Open the installer
  3. Click on install
  4. when it prompts for the local admin password enter it
  5. after the installation try to run gh
  6. See error

img

Logs

PS C:\Users\Advik-B> cd ~
PS C:\Users\Advik-B> cd Griphitor
PS C:\Users\Advik-B\Griphitor> gh repo view --web
gh : The term 'gh' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ gh repo view --web
+ ~~
    + CategoryInfo          : ObjectNotFound: (gh:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Activity

  1. added
    bug
    on Nov 20, 2021
  2. mislav commented on Nov 22, 2021

    @mislav
    Contributor

    @Advik-B The gh installer will put an extra entry to your PATH. In order for that to get picked up, did you restart your terminal window (such as Powershell.exe, Windows Terminal, or Command Prompt) before trying to run gh? If not, then please try that.

    @Riffecx Winget as a package manager simply downloads and runs our MSI installer, so if there is a bug in our installer, we should debug it not by switching to a package manager, but by continuing to run the installer directly until we figure out the problem. Thank you

  3. added
    more-info-needed
    on Nov 22, 2021
  4. Advik-B commented on Nov 23, 2021

    @Advik-B
    Author

    @Advik-B The gh installer will put an extra entry to your PATH. In order for that to get picked up, did you restart your terminal window (such as Powershell.exe, Windows Terminal, or Command Prompt) before trying to run gh? If not, then please try that.

    @Riffecx Winget as a package manager simply downloads and runs our MSI installer, so if there is a bug in our installer, we should debug it not by switching to a package manager, but by continuing to run the installer directly until we figure out the problem. Thank you

    @mislav Yes., I did restart my PC and my terminal. but windows is not able to recognise gh as a command
    Even when I do this: in command prompt

    where gh

    It gives me the error:

    INFO: Could not find files for the given pattern(s).
    
  5. mislav commented on Nov 23, 2021

    @mislav
    Contributor

    @Advik-B If you go to System Properties > Advanced > Environment Variables and check the Path variable there, does it have any entry with "GitHub CLI" in it? It should have been added by our installer.

    If not, you can add one yourself (e.g. add an entry to the path like C:\Program Files (x86)\GitHub CLI), but that still doesn't solve the problem of why the installer didn't add one in the first place. 🤔

  6. Advik-B commented on Nov 24, 2021

    @Advik-B
    Author

    @Advik-B If you go to System Properties > Advanced > Environment Variables and check the Path variable there, does it have any entry with "GitHub CLI" in it? It should have been added by our installer.

    If not, you can add one yourself (e.g. add an entry to the path like C:\Program Files (x86)\GitHub CLI), but that still doesn't solve the problem of why the installer didn't add one in the first place. 🤔

    😞 Looks like I will have stick with git. I hope the installer gets fixed in the future

  7. mislav commented on Nov 24, 2021

    @mislav
    Contributor

    We are working on a better installer: #4276

    In the meantime, like @Riffecx suggested, you can give package managers a try. I like Scoop, but winget seems to be becoming better as well (I just could never figure out how to actually install it).

    Closing in favor of the referenced PR

  8. vegerot commented on Dec 10, 2022

    @vegerot
    Contributor

    @Advik-B The gh installer will put an extra entry to your PATH. In order for that to get picked up, did you restart your terminal window (such as Powershell.exe, Windows Terminal, or Command Prompt) before trying to run gh? If not, then please try that.

    @Riffecx Winget as a package manager simply downloads and runs our MSI installer, so if there is a bug in our installer, we should debug it not by switching to a package manager, but by continuing to run the installer directly until we figure out the problem. Thank you

    As someone used to Linux, I didn't realize I couldn't just open a new PowerShell tab but need to open a new window. Since others will be confused by this too, we should update the documentation to ask people to open a new terminal window.

  9. Omi98 commented on Feb 25, 2024

    @Omi98

    Hello. I have installed the GitHub CI via PowerShell. There were no problems for me. You could try that as well.

    winget install --id GitHub.cli

    Alternatively, you can make an update afterwards.

    winget upgrade --id GitHub.cli

    I hope the installation via PowerShell helps you.

    With kind regards @Riffecx

    This helped me! Thanks.

  10. Omi98 commented on Feb 25, 2024

    @Omi98

    @Advik-B The gh installer will put an extra entry to your PATH. In order for that to get picked up, did you restart your terminal window (such as Powershell.exe, Windows Terminal, or Command Prompt) before trying to run gh? If not, then please try that.

    @Riffecx Winget as a package manager simply downloads and runs our MSI installer, so if there is a bug in our installer, we should debug it not by switching to a package manager, but by continuing to run the installer directly until we figure out the problem. Thank you

    Thank you for mentioning the 'restart' step.
    It helped me fix my gh (not recognizable) issue.

  11. ccn1971 commented on Sep 21, 2024

    @ccn1971

    Hello! I´m unable to run gh workflow list

    C:\Users\crist>gh workflow list
    unable to find git executable in PATH; please install Git for Windows before retrying

    I added the PATH but still not working.
    My OS is Windows 11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmore-info-needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions