When a command, e.g. Command::new("nasm"), in build.rs returns an error, Cargo doesn鈥檛 output the error to standard output. This is especially frustrating when debugging a Makefile that鈥檚 run by Command::new("make").
This is actually done by default to turn down the noise from builds. If you're debugging makefiles I'd recommend having the build command itself forcibly fail to ensure that Cargo prints the output of the build script.
Why not display this output when using --verbose? How do I forcibly fail?
cc: @alexcrichton
You can check the full output in target/build/$crate-$hash/output and you can forcibly fail with a panic!() or a std::os::set_exit_status(nonzero_code). I think that printing this out for --verbose would be a bit _too_ verbose, but we could consider printing where the output goes I suppose. In general a successful build script is something you largely want to ignore 90% of the time.
Note to anyone who found this issue by googling: you can pass -vv now to cargo to display the output. See commit 2c0d6af1739be737133e2385033d1395fbcd8342 and #1106 for details.
@est31 I passed -vv and still don't see the output of println!
At least the output of eprintln! goes through in that case.
Why would I write a build script with println! if I didn't want to see any output when building? Hopefully this will get fixed.
Same issue here. Cargo run does not print. Compiling directly with rustc and running main.exe does print.
There is also -- --nocapture which shows the output when running tests. Maybe it helps but I have not tried.
The only good solution is to write the output you want to see/debug to a file.
Adding -vv outputs too much information and -- --nocapture do not works neither.
For those who still doesn't see any output even after passing -vv:
build.rs like adding a new line(force cargo to rebuild it) and using cargo build -vv, then you'll see the outputs.find . -name output, you will be able to get the path(target/build/$crate-$hash/output) to the output file, then you can cat it.
Most helpful comment
Note to anyone who found this issue by googling: you can pass
-vvnow to cargo to display the output. See commit 2c0d6af1739be737133e2385033d1395fbcd8342 and #1106 for details.