How to use the rebar3 'rich' error messages from the shell?

I recently upgraded rebar3 and noticed that this PR has made error messages colorful and I would like to use formatting from the shell. I have a helper that calls compile:file then code:load_binary. I tried to use this instead:

rebar_compiler_erl:compile("src/my_file.erl", [{undef, "ebin/"}), [{compiler_error_format, rich}], []).

as a test but this threw a bad_generator error when the result was passed to code:load_binary. Is there a better way to do this?

The bad_generator error comes when a bad value is passed to a list comprehension.

The values returned by this compilation function, for what it’s worth, are intended to be used by Rebar3’s own internals, not necessarily to be passed right away to code module functions. Without more information about what you’re passing to these other bits of code, it’s hard to debug what might be going on.

1 Like

Makes sense. I’ll stop trying to muck around with it given it isn’t an exposed interface. Thanks!