Install from source - solidsnakedev/cardano_commands GitHub Wiki

Create folders

mkdir node
mkdir src

Make sure to download latest config files, double check telegram pin message

wget -P $HOME/node https://hydra.iohk.io/build/7578887/download/1/mainnet-config.json
wget -P $HOME/node https://hydra.iohk.io/build/7578887/download/1/mainnet-byron-genesis.json
wget -P $HOME/node https://hydra.iohk.io/build/7578887/download/1/mainnet-shelley-genesis.json
wget -P $HOME/node https://hydra.iohk.io/build/7578887/download/1/mainnet-alonzo-genesis.json

For Debian/Ubuntu, use the following instead:

sudo apt-get update -y
sudo 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

Downloading, unpacking, installing, and updating Cabal

Download the relevant cabal-install (version 3.4.0.0) binary from https://www.haskell.org/cabal/download.html

cd $HOME/src
wget -O cabal.tar.xz https://downloads.haskell.org/~cabal/cabal-install-3.4.0.0/cabal-install-3.4.0.0-x86_64-ubuntu-16.04.tar.xz
tar -xf cabal.tar.xz
rm cabal.tar.xz
mkdir -p ~/.local/bin
mv cabal ~/.local/bin/

Verify that ~/.local/bin is in your PATH:

echo $PATH

If ~/.local/bin is not in the PATH, you need to add the following line to your .bashrc file

echo PATH="$HOME/.local/bin:$PATH" >> $HOME/.bashrc
echo export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH" >> $HOME/.bashrc
echo export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH" >> $HOME/.bashrc

and source the file:

source .bashrc

Update cabal:

cabal update

Confirm that you installed cabal version 3.4.0.0:

cabal --version

Download and install the latest version of GHC:

curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
source .
ghcup install ghc 8.10.7
ghcup install cabal 3.4.0.0
ghcup set ghc 8.10.7
ghcup set cabal 3.4.0.0

Download and install libsodium:

cd $HOME/src
git clone https://github.com/input-output-hk/libsodium
cd libsodium
git checkout 66f017f1
./autogen.sh
./configure
make
sudo make install

Change the working directory to the downloaded source code folder:

cd $HOME/src

Download the Cardano node sources:

git clone https://github.com/input-output-hk/cardano-node.git

Check out the latest version of cardano-node

(choose the tag with the highest version number: TAGGED-VERSION):

TAG_VERSION=1.30.1
cd cardano-node
git fetch --all --recurse-submodules --tags
git tag
git checkout tags/$TAG_VERSION

Configuring the build options

We explicitly use the GHC version that we installed earlier. This avoids defaulting to a system version of GHC that might be older than the one you have installed.

cabal configure --with-compiler=ghc-8.10.4

Note, that for a development build you can avoid installing the custom libsodium library and add the following lines to the local project file:

echo "package cardano-crypto-praos" >>  cabal.project.local
echo "flags: -external-libsodium-vrf" >>  cabal.project.local

Building and installing the node

Build the node and CLI with cabal:

cabal build all

Install the newly built node and CLI commands to the ~/.local/bin directory:

sudo cp $(find $HOME/src/cardano-node/dist-newstyle/build -type f -name "cardano-cli" | grep $TAG_VERSION) ~/.local/bin/cardano-cli
sudo cp $(find $HOME/src/cardano-node/dist-newstyle/build -type f -name "cardano-node" | grep $TAG_VERSION) ~/.local/bin/cardano-node

Copy to external machine

scp /home/cardano/.local/bin/cardano-* "IP Address":/home/cardano

Copy to /.local/bin

cp cardano-* ~/.local/bin/

Verify new version

cardano-cli --version && cardano-node --version

Run node

sudo systemctl start cardano-node.service 

Follow startup process

journalctl -f -t cardano-node