Lesson 1.2 · 6 min
Make and run a project
Chatterbox needs a home: a folder with your code in it and a tool that builds and runs it. In Rust that tool is called cargo, and you will use it hundreds of times. Today you use it three times.
Adds to ChatterboxThe Chatterbox project exists and runs.
Install once
To follow along on your own machine, install Rust from rustup.rs. It installs the compiler and cargo. You can also stay in the page: every code box in this course runs in your browser. But Chatterbox is a real project, so you will want it on your computer by chapter 3, lesson 5 (a preview: that is the first lesson that needs a real terminal).
Make the project
Open a terminal and ask cargo for a new project called chatterbox:
$ cargo new chatterbox Creating binary (application) `chatterbox` package $ cd chatterbox $ ls Cargo.toml src
Cargo made a folder with two things that matter. Cargo.toml is the project's name tag and settings. src/main.rs is where your code lives. Let us look at both.
$ cat Cargo.toml
[package]
name = "chatterbox"
version = "0.1.0"
edition = "2024"
[dependencies]You can ignore most of this for now. name and version do what they say. [dependencies] is an empty shelf where, in chapter 8, you will list the other people's code Chatterbox uses.
And here is the program cargo wrote for you in src/main.rs. It is the same shape as lesson 1.1:
$ cargo run
Hello, world!Run it
cargo run does both jobs from the last lesson: it compiles your code, then runs the result.
$ cargo run
Compiling chatterbox v0.1.0 (~/chatterbox)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.21s
Running `target/debug/chatterbox`
Hello, world!Chatterbox exists
That is it. You now have a project called Chatterbox that compiles and runs. It only says "Hello, world!" so far. In the next lesson you change what it says, and learn what makes println! so flexible.
Say it out loud, then reveal
Which command creates a new project?Reveal
cargo new chatterbox.What is the difference between cargo run and cargo check?Reveal
cargo run compiles and then runs the program. cargo check only checks that the code makes sense, so it is faster.Where does your code live?Reveal
src/main.rs. Cargo.toml holds the project settings.That is lesson 1.2. Tick it off so the course remembers where you are.