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.rs2. 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 --releaseOther wordings of this error
no targets specified in the manifest, either src/lib.rs, src/main.rs
Other build errors
- error: linker `link.exe` not found
- error: linker `cc` not found
- error: failed to run custom build command for `openssl-sys`
- error: failed to select a version for the requirement
- error: failed to select a version for `libsqlite3-sys`... the package `libsqlite3-sys` lin
- error: could not compile `my-crate` (bin "my-crate") due to 1 previous error
- error: package `foo v1.2.3` cannot be built because it requires rustc 1.80 or newer, while
- feature `edition2024` is required
Up next
Find the right pagePaste any Rust errorCompiler codes and build errors in one finder.Read it next →Also worth your time
Did this answer your question?