Installing the Hasura CLI

How do I install Hasura CLI in my machine?

Installation - Mac & Linux

In your Terminal, run the following command:

curl -L https://github.com/hasura/graphql-engine/raw/stable/cli/get.sh | bash

This will install the Hasura CLI in /usr/local/bin. You might have to provide your sudo password depending on the permissions of your /usr/local/bin location.

If you’d prefer to install to a different location other than /usr/local/bin, set the env var INSTALL_PATH:

curl -L https://github.com/hasura/graphql-engine/raw/stable/cli/get.sh | INSTALL_PATH=$HOME/bin bash

There is another way to install Hasura via npm, but if you managed to install with the steps above you already have the super-powers you need to start working with migrations.

Installation - Windows

Download the binary cli-hasura-windows-amd64.exe available under Assets of the latest release from the GitHub release page: https://github.com/hasura/graphql-engine/releases

Rename the downloaded file to hasura. You can add the path to the environment variable PATH for making hasura accessible globally.

For more info, refer to their documentation: https://hasura.io/docs/1.0/graphql/core/hasura-cli/install-hasura-cli.html

(Optional) Adding Hasura shell completion

If you want to hack the matrix, you may want to use autocomplete. The process is different for bash or zsh, so you will want to read their documentation in more detail.

For Mac (bash), run this command:

# 1. Install bash-completion using homebrew:
$ brew install bash-completion

# 2. Add to your ~/.bash_profile:
if [ -f $(brew --prefix)/etc/bash_completion ]; then
   . $(brew --prefix)/etc/bash_completion
fi

# 3. Add the completion file:
$ sudo hasura completion bash --file=$(brew --prefix)/etc/bash_completion.d/hasura

For Zsh (oh-my-zsh):

$ mkdir -p $HOME/.oh-my-zsh/completions
$ hasura completion zsh --file=$HOME/.oh-my-zsh/completions/_hasura

Last updated