Try the demo

error: no library targets found in package

--lib asks for a library, and the package only has a binary.

The error

$ cargo test -p app --lib
error: no library targets found in package `app`

Why it happens

--lib picks the package's library, src/lib.rs. A package with only src/main.rs has none, so there's nothing to pick. cargo build, cargo check and cargo test --doc fail the same way, because doc tests only run for a library.

Across a workspace it's quieter: cargo test --workspace --lib skips the packages that have no library, without a word, so their unit tests never run.

The fix

Name the binaries instead:

cargo test -p app --bins       # the unit tests in every binary
cargo test -p app --bin app    # one binary
cargo test -p app              # all of the package's tests

For a workspace with both kinds of package, cargo test --workspace --lib --bins runs the unit tests of each.

How DMN learned it

It came up, and was fixed, in 2 of our own sessions. DMN kept the fix as one line: dmn-daemon is a binary-only crate, so run its unit tests with `cargo test -p dmn-daemon --bins` (or `--bin dmn-daemon`), never `--lib`, which fails with "no library targets found".

DMN reads your agents' past sessions on your machine. When the same error is fixed the same way in two or more of them, it keeps the fix as a one-line lesson. When the error turns up again, Claude Code is told the fix straight away, and any agent can search what earlier sessions found. How DMN keeps what agents learn.

Stop fixing the same error twice