# Cargo

> The tool that fetches packages and builds code for the Rust language.

**Field:** Software Development  
**Category:** Editors & Tools  
**Also known as:** Cargo Rust, Rust Package Manager, Cargo.toml, crates.io

## Think of it like

It is like a helper who gets the parts, builds the toy and wraps it.

## Definition

Cargo is the package manager and build tool for Rust. It downloads the packages your project needs, called crates. It then builds your code and can run it or test it. Your project's list of crates lives in a file called Cargo.toml. Cargo can also share your own crate on crates.io, the public shelf of Rust packages.

## Example

Jack starts a Rust project with cargo new. He adds one crate to Cargo.toml, and cargo run fetches it, builds and runs.

## Example code

```console
$ cargo new hello
$ cd hello
$ cargo run
Hello, world!
```

Cargo makes the project, builds it and runs it. The new project prints a greeting.

## Why it matters

Every Rust project uses it the same way. You can open any one and build it with one command.

## Common mistake

Calling the Rust compiler by hand on a real project. Let Cargo do it, so the crates and settings come along.

## Three principles

- **Fetch.** It downloads crates from crates.io.
- **Build and run.** One command builds, runs or tests.
- **Cargo.toml.** One file lists the whole project.

## Related terms

- [Rust](https://learn.benibix.com/term/development/rust)
- [Package Manager](https://learn.benibix.com/term/development/package-manager)
- [Build Tool](https://learn.benibix.com/term/development/build-tool)
- [Package Registry](https://learn.benibix.com/term/development/package-registry)
- [Compiler](https://learn.benibix.com/term/development/compiler)

## Taught in

- [Yarn, pnpm, Cargo and Homebrew](https://learn.benibix.com/learn/development-tools/yarn-pnpm-cargo-and-homebrew): Coding Tools, 9/13

![A table of four rows. JavaScript: npm, Yarn and pnpm, all fetching from the npm registry. Python: pip and uv, fetching from PyPI. Rust: Cargo, fetching from crates.io. Apps on Mac and Linux: Homebrew, fetching from its own list, called formulae. Each row runs from the language on the left, through its tools, to its registry on the right.](https://learn.benibix.com/diagrams/dev5-package-managers.svg)

---

Source: https://learn.benibix.com/term/development/cargo
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
