16

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
Andrew Wagner
  • 22,677
  • 21
  • 86
  • 100
  • Haha I was just wishing for the exact same thing yesterday. I don't think it's possible, but it probably wouldn't hurt to request it on the cargo irc channel or repo. – Jorge Israel Peña Nov 23 '14 at 20:37
  • Update: it seems the vim errorformat that ships with rust works as long as your vim is running in the root of your cargo project. – Andrew Wagner Nov 26 '14 at 16:08
  • `cargo test | less` - that probably fails because rust reports errors to the stderr. Try `cargo test 2>&1 | less`. – ArtemGr Nov 28 '14 at 06:04

1 Answers1

18

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

cargo test --color always 2>&1 | less -r
Shun Feng
  • 33
  • 1
  • 5