Create a Rust package with Cargo

JANUARY 18, 2024

First, you must install Rust in your machine, which comes with Cargo. (Installing Rust with rustc will also install Cargo.)

Create a new package

cargo new my_package

Build and run your package

cd my_package
cargo build
cargo run

Adding dependencies

Edit Cargo.toml and add your package dependencies.

// Cargo.toml
base64 = "0.21.7"

You can browse Cargo packages at

See how to compile and run Rust programs without Cargo.