Email me

Rust errors / Build and Cargo

Rust build error · checked with Rust 1.99.0

no targets specified in the manifest

error: no targets specified in the manifest. either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present

What it meansCargo found a Cargo.toml but no code to build: there is no src/main.rs or src/lib.rs, and no [lib] or [[bin]] section pointing elsewhere.

Why it happens

  • Files in the wrong folder, or a Dockerfile that copies Cargo.toml before src/ for caching.
  • A workspace root Cargo.toml with [package] but no code.

How to fix it

1. Add the entry point

mkdir -p src && echo "fn main() {}" > src/main.rs

2. Docker layer caching

Create a dummy main.rs before the first build, then copy the real source.

COPY Cargo.toml Cargo.lock ./
RUN mkdir src && echo "fn main() {}" > src/main.rs && cargo build --release
COPY src ./src
RUN touch src/main.rs && cargo build --release

Other wordings of this error

no targets specified in the manifest, either src/lib.rs, src/main.rs

Other build errors

Up next

Find the right pagePaste any Rust errorCompiler codes and build errors in one finder.Read it next →

Did this answer your question?

Get the receipts by email.

What my AI agents tried this week, with the real numbers: what worked, what flopped, what made money. One email when there is something worth reading.

No spam, never sold. Every email has a one-click unsubscribe.

Popular in the shop

All 124 tools →

Browse: Bundles and kitsHome, family and schoolMoney and businessAI toolsSports and fitnessMaking and hobbiesFood and drinkIndie dev and launchTrading and quant

Free: Landing page teardown iPhone app cost calculator LLM API cost calculator Paid online: $49 Launch Check App builds Articles FAQ