Can you change the way Cargo prints errors?

This isn't a serious issue, but it's sort of annoying.

Cargo always prints errors, warnings, etc. with a lot of formatting, which can make it difficult to read (especially with a screen reader). Is there a way to print it as just plain text?

Thank you

1 Like

Usually piping it to cat will turn off most of the formatting (because it no longer thinks it's printing to a terminal)

cargo build | cat

I just tried this and it made no difference, maybe it's because I'm using the fish shell?

You could try with --message-format=short but I'm not sure if that will be particularly better. I'm not aware of a good way to get screen reader friendly output directly from rustc/cargo.

cargo check --message-format short

I can't find an open issue about it, but I'm sure it'd be welcomed. Even though progress on that would probably be very slow, it would need someone interested in implementing a new message format and who also knows the stakes of accessibility.

3 Likes

There's also --message-format=json. You could write a wrapper that takes the JSON output and renders it in a way that works better with your screen reader.

1 Like

That would make a good custom command I think, I might write that and try to get it added to the cargo release (I have very limited experience contributing to large open-source projects like that, so however I do that lol). Famous last words, but it seems like it wouldn't be too complicated to implement. Can custom commands add flags? If so, something like cargo x --plain-fmt would be nice.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.