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

3.2k Views Asked by At

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
1

There are 1 best solutions below

2
On

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

cargo test --color always 2>&1 | less -r