Installing tokei
By the end of this chapter tokei is installed on your machine, proven by the one check every install must pass — and you know why the obvious routes may not offer you the current version.
The check
Whatever route you take, it ends here:
$ tokei --version
tokei 15.0.0 compiled with serialization support: json
The second half of that line is
worth reading. It names the output
formats this build can write — the
lab's build says json, and chapter
9 shows what happens when you ask
this build for a format it does not
have. Two tokeis at the same version
can differ here, because the formats
are switched on at build time.
The route the lab took: cargo
Tokei is distributed as Rust source through crates.io, and the project's own recommended install is one command with a current Rust toolchain:
cargo install tokei
That sentence hides a condition the lab learned the hard way: current. The build machine's packaged Rust (1.75.0, from Ubuntu 24.04) refused the job outright —
The package requires the Cargo feature called `edition2024`,
but that feature is not stabilized in this version of Cargo (1.75.0).
— because tokei 15 is written in a Rust edition that a 2023 toolchain predates. The fix was a fresh toolchain from rustup (the project's installer at rustup.rs), after which the same command built tokei 15.0.0 in just under five minutes on the lab's two processors. First lesson of the guide, learned before the first count: with a source-distributed tool, the age of your compiler is part of the install instructions.
The other routes, honestly labelled
The lab ran only the cargo route. The following are the project's documented alternatives, named here so you can find them, not vouched for by a transcript:
- Release binaries. The project's GitHub releases page carries ready-made binaries up to tokei 12.1.2. The 13, 14 and 15 releases ship no binaries at all; if you download one, know that it is a 2023 program, and some of what this guide shows (the doc-comment handling in chapter 7, for one) is newer than it.
- Package managers. Some
distributions and Homebrew package
tokei. The lab's Ubuntu 24.04
offered no package at all; yours
may, at whatever version your
distribution has reached. The
--versioncheck tells you what you actually got. - Extra formats at build time.
cargo install tokei --features yaml(and friends) builds a tokei that can write more of chapter 9's formats than the lab's did.
Windows and macOS
The cargo and rustup routes are the same on Windows and macOS, and the commands in this guide run unchanged. Package names and binary downloads differ by platform; the guide does not claim to have tried them.
Check: run tokei --version and
read the whole line, formats
included. If it answers, you have
this chapter.