Skip to main content

Install Open Libra CLI From Source

This guide will walk you through installing the Open Libra CLI by building it from source. The CLI provides essential tools for interacting with the Open Libra network.

Installation Overview

The installation process involves these main steps:

  1. Prerequisites Setup - Install required system dependencies and Rust toolchain for your operating system
  2. Clone Repository - Download the Open Libra Framework source code
  3. Build CLI - Compile the CLI in release mode for optimal performance
  4. Install Binaries - Copy the built binaries to your system PATH
  5. Verify Installation - Confirm the CLI is working correctly

Prerequisites Setup

Before beginning, ensure you have the following tools installed on your system:

  • Rust & Cargo - The Rust programming language and its package manager
  • Git - Version control system for cloning the repository
  • cURL - Command-line tool for downloading files
  • C/C++ toolchain - Compiler and build tools
  • OpenSSL headers - Cryptographic library headers
  • CMake - Cross-platform build system

System-Specific Setup

Select your operating system for detailed installation instructions of all the prerequisites:

Tested on Ubuntu 22.04 LTS and compatible distributions.

System Dependencies

# Update package lists
sudo apt update

# Install required packages
sudo apt install -y \
build-essential \
clang \
llvm \
lld \
cmake \
git \
curl \
pkg-config \
libssl-dev \
libgmp-dev \
libpq-dev

Rust & Cargo Installation

The recommended installation method is rustup, which manages Rust toolchains:

# Download and install Rust
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y

# Activate the toolchain in your current shell
source "$HOME/.cargo/env"

# Verify the installation
rustc --version && cargo --version

To update an existing Rust installation:

rustup update stable

Build & Install the CLI

Once you have all prerequisites installed, follow these steps to build and install the Open Libra CLI:

1. Clone the Repository

git clone https://github.com/0LNetworkCommunity/libra-framework.git
cd libra-framework

2. Build the CLI

# Build in release mode for optimal performance
cargo build --release -p libra

Note: The build process may take several minutes depending on your system's performance.

3. Install the Binary

# Install directly using cargo (recommended)
cargo install --path tools/libra --force

4. Update Your PATH (if needed)

The PATH update is only necessary if you used the manual installation method and chose to install to $HOME/.cargo/bin. If you used cargo install or installed to /usr/local/bin, you can skip this step.

Linux/macOS:

# Add to appropriate shell configuration file
if [[ "$SHELL" == *"zsh"* ]]; then
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc
elif [[ "$SHELL" == *"bash"* ]]; then
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.bashrc && source ~/.bashrc
else
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.profile && source ~/.profile
fi

# Alternative: Check manually and add to your preferred shell config
# echo $SHELL # to see which shell you're using

Windows (PowerShell):

# Add to PATH permanently
$oldPath = [Environment]::GetEnvironmentVariable("PATH", "User")
if ($oldPath -notlike "*$env:USERPROFILE\.cargo\bin*") {
[Environment]::SetEnvironmentVariable("PATH", "$oldPath;$env:USERPROFILE\.cargo\bin", "User")
}

Verify Installation

# Check that the CLI is properly installed
libra --version

# View available commands
libra --help

Troubleshooting

Common Issues

Build fails with OpenSSL errors:

  • Linux: Ensure libssl-dev is installed
  • macOS: Make sure PKG_CONFIG_PATH includes OpenSSL path
  • Windows: Install OpenSSL or use the Windows-specific Rust toolchain

Permission denied when installing:

  • Ensure you have write permissions to $HOME/.cargo/bin
  • On Windows, run PowerShell as Administrator if needed

Command not found after installation:

  • Verify $HOME/.cargo/bin is in your PATH
  • Restart your terminal or source your shell configuration

Compilation takes too long:

  • The initial build can take 10-30 minutes depending on your system
  • Consider using cargo build --release -j $(nproc) to use all CPU cores

Getting Help

If you encounter issues not covered here:

  1. Check the project issues on GitHub
  2. Ensure you're using the latest version of Rust and dependencies

Next Steps

After successful installation:

  1. Run libra --help to explore available commands
  2. Join the Open Libra contributors community on Discord for support and updates

Need pre-built binaries? Visit the binary releases page to learn about downloadable binaries (when available).