Last updated: Apr 5, 2024
Reading time·8 min
The "gh: command not found" error occurs when you try to issue the gh
command in a shell on macOS or Linux without having the GitHub CLI installed.
The "'gh' is not recognized as an internal or external command, operable
program or batch file" command occurs when you try to issue the gh
command
on Windows, without having the GitHub CLI installed.
To resolve the issue, you have to install the GitHub CLI for your operating system.
This article contains step-by-step instructions on how to install the GitHub CLI on all operating systems (Windows, macOS and Linux).
Make sure to click on the subheading that covers your operating system.
If you have Chocolatey installed:
Click on the Search bar and type PowerShell.
Right-click on the PowerShell application and click "Run as administrator".
gh
.# install gh choco install gh -y # Or upgrade gh choco upgrade gh
NOTE: the installation command changes your PATH environment variable.
You have to close and reopen your shell to be able to use the gh
command.
You can also try using the refreshenv
command in PowersShell/CMD.
refreshenv
You first have to run the gh auth login
command to authenticate.
gh auth login
Once you issue the gh auth login
command, the CLI will prompt you how you want
to authenticate.
Follow the steps and run the gh issue list
command to verify everything works.
gh issue list
To install Chocolatey:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
choco
to make sure Chocolatey is installed.Now that you have Chocolatey installed, run the following command to install
curl
.
choco install gh -y
Note that your shell should still be run using elevated permissions.
Now you should be able to use the gh
command.
NOTE: the installation command changes your PATH environment variable.
You have to close and reopen your shell to be able to use the gh
command.
You can also try using the refreshenv
command in PowersShell/CMD.
refreshenv
You first have to run the gh auth login
command to authenticate.
gh auth login
Once you issue the gh auth login
command, the CLI will prompt you how you want
to authenticate.
Follow the steps and run the gh issue list
command to verify everything works.
gh issue list
If you use scoop
, you can install the GitHub CLI by running the following
command.
# to install gh scoop install gh # or to update gh scoop update gh
NOTE: the installation command changes your PATH environment variable.
You have to close and reopen your shell to be able to use the gh
command.
You can also try using the refreshenv
command in PowersShell/CMD.
refreshenv
You first have to run the gh auth login
command to authenticate.
gh auth login
Once you issue the gh auth login
command, the CLI will prompt you how you want
to authenticate.
Follow the steps and run the gh issue list
command to verify everything works.
gh issue list
If you'd rather use WinGet to install gh
on Windows, run the following command
instead.
# To install the GitHub CLI winget install --id GitHub.cli # Or to update the GitHub CLI winget upgrade --id GitHub.cli
NOTE: the installation command changes your PATH environment variable.
You have to close and reopen your shell to be able to use the gh
command.
You can also try using the refreshenv
command in PowersShell/CMD.
refreshenv
You first have to run the gh auth login
command to authenticate.
gh auth login
Once you issue the gh auth login
command, the CLI will prompt you how you want
to authenticate.
Follow the steps and run the gh issue list
command to verify everything works.
gh issue list
You can use Homebrew to install the GitHub CLI (gh) on macOS.
Open your terminal and run the following command.
# To install the GitHub CLI brew install gh # Or to update the GitHub CLI brew upgrade gh
NOTE: the installation command changes your PATH environment variable.
You have to close and reopen your shell to be able to use the gh
command.
You first have to run the gh auth login
command to authenticate.
gh auth login
Once you issue the gh auth login
command, the CLI will prompt you how you want
to authenticate.
Follow the steps and run the gh issue list
command to verify everything works.
gh issue list
If you'd rather use MacPorts to install the GitHub CLI, run the following command instead.
# To install the GitHub CLI sudo port install gh # To upgrade the GitHub CLI sudo port selfupdate && sudo port upgrade gh
NOTE: the installation command changes your PATH environment variable.
You have to close and reopen your shell to be able to use the gh
command.
You first have to run the gh auth login
command to authenticate.
gh auth login
Once you issue the gh auth login
command, the CLI will prompt you how you want
to authenticate.
Follow the steps and run the gh issue list
command to verify everything works.
gh issue list
You can also use Spack to install the GitHub CLI on macOS.
Open your terminal and run the following command.
# To install the GitHub CLI spack install gh # Or to upgrade the GitHub CLI spack uninstall gh && spack install gh
NOTE: the installation command changes your PATH environment variable.
You have to close and reopen your shell to be able to use the gh
command.
You first have to run the gh auth login
command to authenticate.
gh auth login
Once you issue the gh auth login
command, the CLI will prompt you how you want
to authenticate.
Follow the steps and run the gh issue list
command to verify everything works.
gh issue list
You can also use Anaconda to install the GitHub CLI.
Open your terminal and run the following command.
conda install gh --channel conda-forge
If you need to upgrade the GitHub CLI, run the following command instead.
conda update gh --channel conda-forge
NOTE: the installation command changes your PATH environment variable.
You have to close and reopen your shell to be able to use the gh
command.
You first have to run the gh auth login
command to authenticate.
gh auth login
Once you issue the gh auth login
command, the CLI will prompt you how you want
to authenticate.
Follow the steps and run the gh issue list
command to verify everything works.
gh issue list
If you need to install the GitHub CLI on Debian, Ubuntu or Raspberry Pi OS, open your terminal and issue the following commands.
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y) curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \ && sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \ && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ && sudo apt update \ && sudo apt install gh -y
If you need to upgrade the GitHub CLI, run the following command.
sudo apt update sudo apt install gh
NOTE: the installation command changes your PATH environment variable.
You have to close and reopen your shell to be able to use the gh
command.
You first have to run the gh auth login
command to authenticate.
gh auth login
Once you issue the gh auth login
command, the CLI will prompt you how you want
to authenticate.
Follow the steps and run the gh issue list
command to verify everything works.
gh issue list
If you need to install the GitHub CLI on Fedora, CentOS or Red Hat, open your terminal and run the following commands.
sudo dnf install 'dnf-command(config-manager)' sudo dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo sudo dnf install gh
The commands above install the GitHub CLI from the package's repository.
You can also install the package using the community repository.
sudo dnf install gh
If you need to upgrade the GitHub CLI on Fedora, CentOS or Red Hat, run the following command.
sudo dnf update gh
NOTE: the installation command changes your PATH environment variable.
You have to close and reopen your shell to be able to use the gh
command.
You first have to run the gh auth login
command to authenticate.
gh auth login
Once you issue the gh auth login
command, the CLI will prompt you how you want
to authenticate.
Follow the steps and run the gh issue list
command to verify everything works.
gh issue list
If you need to install the GitHub CLI on Amazon Linux 2 using yum
, issue the
following commands.
type -p yum-config-manager >/dev/null || sudo yum install yum-utils sudo yum-config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo sudo yum install gh
GitHub recently changed its GPG signing key.
If you get a GPG signing key error:
sudo yum-config-manager --disable gh-cli
sudo yum-config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
sudo yum update gh
NOTE: the installation command changes your PATH environment variable.
You have to close and reopen your shell to be able to use the gh
command.
You first have to run the gh auth login
command to authenticate.
gh auth login
Once you issue the gh auth login
command, the CLI will prompt you how you want
to authenticate.
Follow the steps and run the gh issue list
command to verify everything works.
gh issue list
If you need to install the GitHub CLI on openSUSE, run the following commands.
sudo zypper addrepo https://cli.github.com/packages/rpm/gh-cli.repo sudo zypper ref sudo zypper install gh
If you need to upgrade the GitHub CLI, run the following commands instead.
sudo zypper ref sudo zypper update gh
NOTE: the installation command changes your PATH environment variable.
You have to close and reopen your shell to be able to use the gh
command.
You first have to run the gh auth login
command to authenticate.
gh auth login
Once you issue the gh auth login
command, the CLI will prompt you how you want
to authenticate.
Follow the steps and run the gh issue list
command to verify everything works.
gh issue list
You can learn more about the related topics by checking out the following tutorials: