Installing cardano-node and cardano-cli from source
#
OverviewThis guide will show you how to compile and install the cardano-node
and cardano-cli
into your operating system of choice, directly from the source-code. It will enable you to interact with the Cardano blockchain, including but not limited to sending/receiving transactions, creating NFTs, posting transaction metadata into the blockchain, minting/burning native tokens, creating a stake pool, executing smart contracts, and so much more!
note
If you want to avoid compiling the binaries yourself, you can download the latest versions of cardano-node
and cardano-cli
from the links below.
There are newer binaries available:
The components can be built and run on Windows and MacOS, but we recommend that stake pool operators use Linux in production to take advantage of the associated performance advantages.
#
PrerequisitesTo set up the components, you will need:
- Windows, MacOS, or Linux for your operating system
- A CPU with at least two cores
- 8GB of RAM and at least 10GB of free disk space
#
Choose your Platform#
LinuxIn this section, we will walk you through the process of downloading, compiling, and installing cardano-node
and cardano-cli
into your Linux-based operating system.
#
Installing Operating System dependenciesTo download the source code and build it, you need the following packages and tools on your Linux system:
- the version control system
git
, - the
gcc
C-compiler, - C++ support for
gcc
, - developer libraries for the arbitrary precision library
gmp
, - developer libraries for the compression library
zlib
, - developer libraries for
systemd
, - developer libraries for
ncurses
, ncurses
compatibility libraries,- the Haskell build tool
cabal
, - the GHC Haskell compiler (version
8.10.4
or above).
In Redhat, Fedora, and Centos:
sudo yum update -ysudo yum install git gcc gcc-c++ tmux gmp-devel make tar xz wget zlib-devel libtool autoconf -ysudo yum install systemd-devel ncurses-devel ncurses-compat-libs -y
For Debian/Ubuntu, use the following instead:
sudo apt-get update -ysudo apt-get install automake build-essential pkg-config libffi-dev libgmp-dev libssl-dev libtinfo-dev libsystemd-dev zlib1g-dev make g++ tmux git jq wget libncursesw5 libtool autoconf -y
If you are using a different flavor of Linux, you will need to use the correct package manager for your platform instead of yum
or apt-get
, and the names of the packages you need to install might differ.
#
Installing GHC and CabalThe fastest way to install GHC (Glassglow Haskell Compiler) and Cabal (Common Architecture for Building Applications and Libraries) is to use ghcup.
Use the following command to install ghcup
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
Please follow the instructions and provide the necessary input to the installer. Once complete, you should have ghc
and cabal
installed to your system.
note
ghcup
will try to detect your shell and ask you to add it to the environment variables. Please restart your shell/terminal after installing ghcup
You can check if ghcup
has been installed correctly by typing ghcup --version
into the terminal. You should see something similar to the following:
The GHCup Haskell installer, version v0.1.14.1
ghcup
will install the latest stable version of ghc
. However, as of the time of writing this, Input-Output recommends using ghc 8.10.4
. So, we will use ghcup
to install and switch to the required version.
ghcup install ghc 8.10.4ghcup set ghc 8.10.4
Finally, we check if we have the correct ghc
and cabal
versions installed.
Check ghc
version:
ghc --version
You should see something like this:
The Glorious Glasgow Haskell Compilation System, version 8.10.4
Check cabal
version:
cabal --version
You should see something like this:
cabal-install version 3.4.0.0compiled using version 3.4.0.0 of the Cabal library
important
Please confirm that the versions you have installed match the recommended versions above. If not, check if you have missed any of the previous steps.
#
Downloading & CompilingLet's create a working directory to store the source-code and builds for the components.
mkdir -p ~/cardano-srccd ~/cardano-src
Next, we will download, compile and install libsodium
.
git clone https://github.com/input-output-hk/libsodiumcd libsodiumgit checkout 66f017f1./autogen.sh./configuremakesudo make install
Then we will add the following environment variables to your shell profile. E.G ~/.zshrc
or ~/.bashrc
depending on what shell application you are using. Add the following to the bottom of your shell profile/config file so that the compiler can be aware that libsodium
is installed on your system.
export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
Once saved, we will then reload your shell profile to use the new variables. We can do that by typing source ~/.bashrc
or source ~/.zshrc
(depending on the shell application you use).
Now we are ready to download, compile and install cardano-node
and cardano-cli
. But first, we have to make sure we are back at the root of our working directory:
cd ~/cardano-src
Download the cardano-node
repository:
git clone https://github.com/input-output-hk/cardano-node.gitcd cardano-nodegit fetch --all --recurse-submodules --tags
Switch the repository to the latest tagged commit:
git checkout tags/1.27.0
important
You can check the latest available version/tag by visiting the cardano-node
Github Release page. At the time of writing this, the current version is 1.27.0
.
#
Configuring the build optionsWe explicitly use the ghc
version that we installed earlier. This avoids defaulting to a system version of ghc
that might be newer or older than the one you have installed.
cabal configure --with-compiler=ghc-8.10.4
Update the local project file to use libsodium
that you installed earlier.
echo "package cardano-crypto-praos" >> cabal.project.localecho " flags: -external-libsodium-vrf" >> cabal.project.local
#
Building and installing the nodeWe can now build the Haskell-based
cardano-node
to produce executable binaries.
cabal build all
Install the newly built node and CLI commands to the ~/.local/bin directory:
mkdir -p ~/.local/bincp -p "$(./scripts/bin-path.sh cardano-node)" ~/.local/bin/cp -p "$(./scripts/bin-path.sh cardano-cli)" ~/.local/bin/
We have to add this line below our shell profile so that the shell/terminal can recognize that cardano-node
and cardano-cli
are global commands. (~/.zshrc
or ~/.bashrc
depending on the shell application you use)
export PATH="~/.local/bin/:$PATH"
Once saved, reload your shell profile by typing source ~/.zshrc
or source ~/.bashrc
(depending on the shell application you use).
Check the version that has been installed:
cardano-cli --versioncardano-node --version
Congratulations, you have successfully installed Cardano components into your Linux system! ๐๐๐
Next, we will talk about how to run cardano-node.
#
MacOSIn this section, we will walk you through the process of downloading, compiling, and installing cardano-node
and cardano-cli
into your MacOS-based operating system.
note
Please note that this guide only supports Intel-based Apple MacOS hardware. Apple Silicon (M1) hardware guide is still in progress.
#
Installing Operating System dependenciesTo download the source code and build it, you need the following packages and tools on your MacOS system:
- Xcode - The Apple Development IDE and SDK/Tools
- Xcode Command Line Tools, you can install it by typing
xcode-select --install
in the terminal. - Homebrew - The Missing Package Manager for MacOS (or Linux)
#
Installing Homebrew packagesFor the cardano-node
and cardano-cli
components to compile properly, we will need to install some libraries via brew
:
brew install jqbrew install libtoolbrew install autoconfbrew install automakebrew install pkg-config
#
Installing GHC and CabalThe fastest way to install GHC (Glassglow Haskell Compiler) and Cabal (Common Architecture for Building Applications and Libraries) is to use ghcup.
Use the following command to install ghcup
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
Please follow the instructions and provide the necessary input to the installer. Once complete, you should have ghc
and cabal
installed on your system.
note
ghcup
will try to detect your shell and will ask you to add it to the environment variables. Please restart your shell/terminal after installing ghcup
You can check if ghcup
has been installed properly by typing ghcup --version
into the terminal. You should see something similar to the following:
The GHCup Haskell installer, version v0.1.14.1
ghcup
will install the latest stable version of ghc
. However, as of the time writing this, Input-Output recommends using ghc 8.10.4
. So, we will use ghcup
to install and switch to the required version.
ghcup install ghc 8.10.4ghcup set ghc 8.10.4
Finally, we check if we have the correct ghc
and cabal
versions installed.
Check ghc
version:
ghc --version
You should see something like this:
The Glorious Glasgow Haskell Compilation System, version 8.10.4
Check cabal
version:
cabal --version
You should see something like this:
cabal-install version 3.4.0.0compiled using version 3.4.0.0 of the Cabal library
important
Please confirm that the versions you have installed matches the recommended versions above. If not, check if you have missed any of the previous steps.
#
Downloading & CompilingLet's create a working directory to store the source-code and builds for the components.
mkdir -p ~/cardano-srccd ~/cardano-src
Next, we will download, compile and install libsodium
.
git clone https://github.com/input-output-hk/libsodiumcd libsodiumgit checkout 66f017f1./autogen.sh./configuremakesudo make install
Then we will add the following environment variables to your shell profile. E.G ~/.zshrc
or ~/.bashrc
depending on what shell application you are using. Add the following to the bottom of your shell profile/config file so the compiler can be aware that libsodium
is installed on your system.
export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
Once saved, we will then reload your shell profile to use the new variables. We can do that by typing source ~/.bashrc
or source ~/.zshrc
(depending on the shell application you use).
Now we are ready to download, compile and install cardano-node
and cardano-cli
. But first, we have to make sure we are back at the root of our working directory:
cd ~/cardano-src
Download the cardano-node
repository:
git clone https://github.com/input-output-hk/cardano-node.gitcd cardano-nodegit fetch --all --recurse-submodules --tags
Switch the repository to the latest tagged commit:
git checkout tags/1.27.0
important
You can check the latest available version / tag by visiting the cardano-node
Github Release page. At the time of writing this, the current version is 1.27.0
.
#
Configuring the build optionsWe explicitly use the ghc
version that we installed earlier. This avoids defaulting to a system version of ghc
that might be newer or older than the one you have installed.
cabal configure --with-compiler=ghc-8.10.4
Update the local project file to use libsodium
that you installed earlier.
echo "package cardano-crypto-praos" >> cabal.project.localecho " flags: -external-libsodium-vrf" >> cabal.project.local
#
Building and installing the nodecabal build all
Install the newly built node and CLI to the ~/.local/bin directory:
mkdir -p ~/.local/bincp -p "$(./scripts/bin-path.sh cardano-node)" ~/.local/bin/cp -p "$(./scripts/bin-path.sh cardano-cli)" ~/.local/bin/
We have to add this line below our shell profile so that the shell/terminal can recognize that cardano-node
and cardano-cli
are global commands. (~/.zshrc
or ~/.bashrc
depending on the shell application you use)
export PATH="~/.local/bin/:$PATH"
Once saved, reload your shell profile by typing source ~/.zshrc
or source ~/.bashrc
(depending on the shell application you use).
Check the version that has been installed:
cardano-cli --versioncardano-node --version
Congratulations, you have successfully installed Cardano components into your MacOS system! ๐๐๐
Next, we will talk about how to run cardano-node.
#
Windowsimportant
Currently, the Windows installation guide is still in progress. In the meantime, we recommend using WSL (Windows Subsystem for Linux) to get a Linux environment on top of Windows. Once installed, you can use the Linux guide to install and run cardano-node
within WSL.