-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Cargo doesn’t display output from a command in build.rs #985
Comments
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 |
cc: @alexcrichton |
You can check the full output in |
Note to anyone who found this issue by googling: you can pass |
Document how to make `build.rs` write to the terminal Documenting the solution mentioned here: #985
@est31 I passed |
At least the output of |
Why would I write a build script with |
Same issue here. Cargo run does not print. Compiling directly with rustc and running main.exe does print. |
There is also |
The only good solution is to write the output you want to see/debug to a file. Adding |
For those who still doesn't see any output even after passing
|
You shouldn't use |
That link states that any output not starting with |
Cargo shouldn't use |
I don't think this issue should be closed. It's very convenient to use |
@notdanilo , I opened a new issue based on your suggestion with an alternative solution:
If anyone likes it, or have a different proposal, please, upvote it or comment on it: #10475 |
I mentioned this on the new linked issue, but it might be worth mentioning here that you can currently do So, for quick debugging of a build script you could use this drop in replacement for macro_rules! p {
($($tokens: tt)*) => {
println!("cargo:warning={}", format!($($tokens)*))
}
} usage example: // in build.rs
macro_rules! p {
($($tokens: tt)*) => {
println!("cargo:warning={}", format!($($tokens)*))
}
}
fn main() {
let x = 42;
p!("{x}");
} |
Another (terrible) hack, but if you |
Thanks, Really appreciated |
1 similar comment
This comment was marked as duplicate.
This comment was marked as duplicate.
I've managed to debug |
I have a project where my rust crate is using some dynamic libraries (also in Rust). So, my build workflow is to basically compile the dynamic libraries, move their binaries somewhere, and then build my main project. |
That answer is in the second post
As other posts in this thread say
|
Cannot be done easily in CI
Then you have tens of thousands of lines of log for any complex projects and extremely cumbersome to parse in CI
Very noisy when collaborating with many people on a shared project. |
When a command, e.g.
Command::new("nasm")
, inbuild.rs
returns an error, Cargo doesn’t output the error to standard output. This is especially frustrating when debugging a Makefile that’s run byCommand::new("make")
.The text was updated successfully, but these errors were encountered: