I am trying to use the cargo +nightly-2022-08-15 contract build command on a cargo contract new ___, but am experiencing the error below.

Finished dev [unoptimized + debuginfo] target(s) in 0.15s
 [2/5] Building cargo project
ERROR: No path specified, and the default `src/main.rs` was not found

The cargo +nightly-2022-08-15 contract test was executed successfully.

Can someone please help me understand why I'm seeing this error with a possible workaround please? I guess another way to phrase my question is, where exactly from the root directory does the build command expect there to be a an "src/main.rs"?

  • 1
    Could you share your directory structure, and where you are building from? Also, double check if there is a parent directory with a Cargo.toml as outlined here: stackoverflow.com/questions/61134990/… Sep 19, 2022 at 15:16
  • @PeterWhite resolved. My contract was nested in a parent containing a separate Cargo.toml file. All I did was move the contract folder out. Thank you very much.
    – kenta_desu
    Sep 20, 2022 at 3:27
  • Great, glad to hear it! :) Sep 20, 2022 at 14:43

1 Answer 1


Moving comment to answer:

Double check if there is a parent directory with a Cargo.toml as outlined here https://stackoverflow.com/questions/61134990/cargo-would-not-build-even-when-src-main-rs-is-available

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.