{"id":308,"hash":"fb2772b16af7a482dfa34acd10ee011d1993307c1d0f67203aa32765f2d4124a","pattern":"failed to parse manifest - no targets specified","full_message":"I am new to Rust and attempting to build a test project with Cargo. My Cargo.toml looks like:\n\n[package]\nname = \"rust-play\"\nversion = \"0.0.1\"\nauthors = [ \"Bradley Wogsland <omitted>\" ]\n\n(but the actual TOML file doesn't omit my email). When I cargo build I am getting the following error:\n\n  error: failed to parse manifest at /Users/wogsland/Projects/rust-play/Cargo.toml\n\n  \n  Caused by:\n    no targets specified in the manifest\n    either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present\n\nMy main function is in a src/test.rs file. Do I need to specify that in the TOML file? If so, how? I tried adding\n\ntarget = \"src/test.rs\"\n\nto no avail.","ecosystem":"cargo","package_name":"rust-cargo","package_version":null,"solution":"As the error says:\n\n  either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present\n\nSo the direct answer is to add a [[bin]] section:\n\n[[bin]]\nname = \"test\"\npath = \"src/test.rs\"\n\nHowever, it's far more usual to just place the file in the expected location: src/main.rs. You could also place it in src/bin/test.rs if you plan on having multiple binaries.\n\nIf it's actually for testing your code, then unit tests go in the same file as the code they are testing and integration tests go in tests/foo.rs.","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/37491436/failed-to-parse-manifest-no-targets-specified","votes":53,"created_at":"2026-04-19T04:41:50.435830+00:00","updated_at":"2026-04-19T04:52:30.365268+00:00"}