Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Only show first screenful of compile errors in Rust when building with Cargo?

Is there a way to get rustc to only output the first few errors when compiling with Cargo, or even better, to print the oldest errors last? It seems the default threshold for aborting the compile is set quite high:

error: aborting due to 25 previous errors

I don't have the patience to scroll through 6-10 pages of text to find the first error.

Normally I would handle this by compiling inside my editor (vim), but the vim configuration that ships with rust doesn't seem to be setting errorformat properly.

Piping to a pager is also failing for some reason:

cargo test | less
like image 709
Andrew Wagner Avatar asked Nov 22 '14 21:11

Andrew Wagner


1 Answers

cargo test writes errors to stderr, so you have to redirect stderr to stdout like this:

cargo test --color always 2>&1 | less -r
like image 116
Theemathas Chirananthavat Avatar answered Oct 30 '22 01:10

Theemathas Chirananthavat