**Cargo** is the [[Rust]] [[package manager]]. It downloads your package dependencies, compiles the package, makes distributable packages and uploads them to https://crates.io, the community's package registry.
## Basic commands
To create a new project using Cargo, run:
```shell
cargo new project_name
```
This will create a new project directory (named `project_name`), containing the bare-bones structure for a binary application: a `src` directory containing an entry-point file (`main.rs`) and a `Cargo.toml` manifest file.
![[Rust Compilation#Compiling using Cargo]]
## Using crates
When programming in [[Rust]], we can use third-party packages (called crates within the context of [[Cargo]]) by specifying the dependencies in the our `Cargo.toml` file (within the `[dependencies]` section).
By default, Cargo handles [[Semantic Versioning]], which makes the specification `rand = "0.8.5"` equivalent to `rand = "^0.8.5"`; that is, all versions over `0.8.5` but lower than `0.9.0` (since no breaking changes should be introduced in minor-version bumps).
The dependencies fetched by cargo come from https://crates.io, the default crate registry.
When [[Rust Compilation|compiling using Cargo]], a lock-file is generated (`Cargo.lock`), which freezes all the dependencies until it is explicitly updated. This file can be used to ensure reproducible builds. To update it, simply run `cargo update`