Rust
This guide covers setting up Rust development with rustup and Cargo.
Installation
We recommend using rustup, the official Rust toolchain installer.
- Windows
- macOS
- Linux
# Using winget
winget install Rustlang.Rustup
# Restart your terminal after installation
Or download the installer from rustup.rs.
info
On Windows, you may need to install the Visual Studio C++ Build Tools for linking.
# Install rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Follow the prompts (default installation is recommended)
# Add Cargo to your PATH (add to ~/.zshrc for persistence)
source "$HOME/.cargo/env"
# Install rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Follow the prompts (default installation is recommended)
# Add Cargo to your PATH (add to ~/.bashrc for persistence)
source "$HOME/.cargo/env"
# Install build essentials if not present (Ubuntu/Debian)
sudo apt-get update
sudo apt-get install -y build-essential
Verify Installation
rustc --version
cargo --version
Cargo
Cargo is Rust's build system and package manager. It handles dependency management, compilation, testing, and publishing.
Common Cargo Commands
# Create a new project
cargo new my-project
# Build project
cargo build
# Build optimized release
cargo build --release
# Run project
cargo run
# Run tests
cargo test
# Format code
cargo fmt
# Lint code
cargo clippy
Set Up Cargo with JFrog
- Go to https://p6m.jfrog.io
- Login
- Navigate to Profile → Set Me Up → Cargo
- Click Generate Token and Create Instructions
- Follow the instructions to configure your
~/.cargo/config.toml
Related
- The Rust Programming Language (Book) - Official Rust documentation
- Cargo Configuration - Configure Cargo registries