Skip to main content

Compiling Cardano Node

After you finish installing GHC and Cabal successfully, you can compile Cardano Node from source code.

To compile Cardano Node:

1. Using a terminal window on the computer hosting your block-producing node, to ensure that development headers for the Sodium cryptographic library are NOT installed, type:

sudo apt remove libsodium-dev

2. Type the following command to navigate to the working directory that you created when Installing Shared Libraries:

cd $HOME/git

3. To download Cardano Node source code, type:

git clone https://github.com/IntersectMBO/cardano-node.git
cd cardano-node
git fetch --all --recurse-submodules --tags

4. To switch the repository that you downloaded to your local computer in step 3 to the latest tagged commit, type:

git checkout $(curl -s https://api.github.com/repos/IntersectMBO/cardano-node/releases/latest | jq -r .tag_name)

Challenge
Challenge

Typing a dollar sign ($) before a command in parentheses refers to the output of the command in parentheses. The pipe character (|) redirects output from one command to input of another command. Using a Web browser, navigate to the above URL to display the data that the curl command retrieves, and then confirm the value of the tag_name attribute that the jq command selects.

5. To adjust the project configuration to disable optimization and set the recommended compiler version, type:

cabal update
cabal configure -O0 -w ghc-9.6.7

6. To produce executable cardano-node, cardano-cli and cardano-tracer binaries, type:

cabal build all
cabal build cardano-cli
cabal build cardano-tracer

Note
Note

Depending on the processing power of your computer, the build process requires about 20 minutes to complete.

7. To copy the cardano-node and cardano-cli binaries that you produced in step 6 into the /usr/local/bin directory, type:

sudo cp -p "$(./scripts/bin-path.sh cardano-node)" /usr/local/bin/cardano-node
sudo cp -p "$(./scripts/bin-path.sh cardano-cli)" /usr/local/bin/cardano-cli

8. To install the cardano-tracer binary that you produced in step 6 in the /usr/local/bin directory, type:

cabal install cardano-tracer --installdir=/usr/local/bin --overwrite-policy=always

9. To confirm that the version installed on your computer matches the latest release available in the Cardano Node GitHub repository, type:

cardano-node --version
cardano-cli --version
cardano-tracer --version

10. On each computer hosting a relay or block-producing node in your stake pool configuration, repeat steps 1 to 9