Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error message for missing main function in example is non-specific #1361

Closed
huonw opened this issue Feb 27, 2015 · 3 comments
Closed

error message for missing main function in example is non-specific #1361

huonw opened this issue Feb 27, 2015 · 3 comments
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself.

Comments

@huonw
Copy link
Member

huonw commented Feb 27, 2015

$ cargo new missing-main
$ cd missing-main
$ mkdir examples
$ touch examples/foo.rs
$ cargo build
   Compiling missing-main v0.0.1 (file:///home/huon/tmp/missing-main)
error: main function not found
error: aborting due to previous error
Could not compile `missing-main`.

Running with --verbose does at least print the last command run (pointing the finger at examples/foo,rs), but it seems bad to have a raw error: printed like this.

@huonw huonw added the A-diagnostics Area: Error and warning messages generated by Cargo itself. label Feb 27, 2015
@alexcrichton
Copy link
Member

Hm perhaps this is more of a compiler issue than a Cargo issue? Cargo currently does not interpret errors at all, it just ships them back to the front. Although one possible step Cargo could take is:

Could not compile `missing-main` at `examples/foo.rs`

(which seems plausible?)

@carols10cents
Copy link
Member

Triage: this is still a problem, but I had to either cargo run --example foo or cargo test; looks like cargo build no longer builds examples by default.

The error messages still don't mention examples/foo.rs though, which is the problem.

$ cargo new missing-main
     Created library `missing-main` project
$ cd missing-main
$ mkdir examples
$ touch examples/foo.rs
$ cargo build
   Compiling missing-main v0.1.0 (file:///Users/carolnichols/rust/missing-main)
    Finished dev [unoptimized + debuginfo] target(s) in 0.19 secs

$ cargo build --verbose
       Fresh missing-main v0.1.0 (file:///Users/carolnichols/rust/missing-main)
    Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs

$ cargo run --example foo
   Compiling missing-main v0.1.0 (file:///Users/carolnichols/rust/missing-main)
error: main function not found

error: aborting due to previous error

error: Could not compile `missing-main`.

To learn more, run the command again with --verbose.

$ cargo run --example foo --verbose
   Compiling missing-main v0.1.0 (file:///Users/carolnichols/rust/missing-main)
     Running `rustc --crate-name foo examples/foo.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=799ee0edb02a8799 -C extra-filename=-799ee0edb02a8799 --out-dir /Users/carolnichols/rust/missing-main/target/debug/examples -L dependency=/Users/carolnichols/rust/missing-main/target/debug/deps --extern missing_main=/Users/carolnichols/rust/missing-main/target/debug/deps/libmissing_main-4976ac668ccc2721.rlib`
error: main function not found

error: aborting due to previous error

error: Could not compile `missing-main`.

Caused by:
  process didn't exit successfully: `rustc --crate-name foo examples/foo.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=799ee0edb02a8799 -C extra-filename=-799ee0edb02a8799 --out-dir /Users/carolnichols/rust/missing-main/target/debug/examples -L dependency=/Users/carolnichols/rust/missing-main/target/debug/deps --extern missing_main=/Users/carolnichols/rust/missing-main/target/debug/deps/libmissing_main-4976ac668ccc2721.rlib` (exit code: 101)

$ cargo test
   Compiling missing-main v0.1.0 (file:///Users/carolnichols/rust/missing-main)
error: main function not found

error: aborting due to previous error

error: Could not compile `missing-main`.
Build failed, waiting for other jobs to finish...
error: build failed

@ehuss
Copy link
Contributor

ehuss commented Nov 30, 2018

I think this is resolved by rust-lang/rust#48706.

@ehuss ehuss closed this as completed Nov 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself.
Projects
None yet
Development

No branches or pull requests

4 participants