erlang / rebar3

Erlang build tool that makes it easy to compile and test Erlang applications and releases.
http://www.rebar3.org
Apache License 2.0
1.7k stars 519 forks source link

REBAR_COLOR=none doesn't remove all colors #2605

Open saleyn opened 3 years ago

saleyn commented 3 years ago

Environment

$ rebar3 report
Rebar3 report
 version 3.16.1+build.5052.refa575f0e5
 generated at 2021-08-11T14:10:35+00:00
=================
Please submit this along with your issue at https://github.com/erlang/rebar3/issues (and feel free to edit out private information, if any)
-----------------
Task: 
Entered as:

-----------------
Operating System: x86_64-pc-linux-gnu
ERTS: Erlang/OTP 24 [erts-12.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]
Root Directory: /usr/lib/erlang
Library directory: /usr/lib/erlang/lib
-----------------
Loaded Applications:
bbmustache: 1.10.0
certifi: 2.6.1
cf: 0.3.1
common_test: 1.20.3
compiler: 8.0
crypto: 5.0
cth_readable: 1.5.1
dialyzer: 4.4
edoc: 1.0
erlware_commons: 1.5.0
eunit: 2.6.1
eunit_formatters: 0.5.0
getopt: 1.0.1
inets: 7.4
kernel: 8.0
providers: 1.8.1
public_key: 1.11
relx: 4.4.0
sasl: 4.1
snmp: 5.9
ssl_verify_fun: 1.1.6
stdlib: 3.15
syntax_tools: 2.6
tools: 3.5
...

Current behaviour

$ REBAR_COLOR=none rebar3 compile Verifying dependencies... Analyzing applications... Compiling payments Compiling src/payments_engine.erl failed %% <-- This line appears in bold color src/test.erl:64:69: syntax error before: '{'

Because of this vim is occasionally unable to determine the file name of the module with error, and cannot jump to that line after :make is invoked.

Expected behaviour

All output should not be colorized.

ferd commented 3 years ago

When I try it here it does remove all color, but leaves the bold font in place. All output styling of this kind can be removed by using TERM=dumb as an environment variable, which lets rebar3 assume that the receiving end isn't a full blown terminal. If you're building from an editor, that's probably what you should specify as a terminal option?

saleyn commented 3 years ago

That does work, though I would assume that the intention of the REBAR_COLOR was to remove all color escaping chars including bold, no?

Do you know if there is a way to have vim set it the TERM automatically when executing :make? The desired functionality would be to leave the colors when typing make from the shell, and remove colors when executing make from the vim.

saleyn commented 3 years ago

Actually, I think I figured it out:

$ cat ~/.vim/ftplugin/erlang.vim 
setlocal makeprg=TERM=dumb\ make
ferd commented 3 years ago

Yeah that's a good question. I assumed that turning off the color meant the colors and not the color codes, so I went digging to see and it may have been accidental:

https://github.com/erlang/rebar3/blob/master/src/rebar_log.erl#L114-L115 sets the color code for bold text, and sends it to erlware_common's logging module, which is seemingly the thing that adds red (https://github.com/erlware/erlware_commons/blob/master/src/ec_cmd_log.erl#L167-L169).

This means that erlware_commons would normally filter out the bold, and its addition might be considered somewhat buggy on our end. We could arguably do the check on our side of it before bolding as well I guess, drop the bold, or patch up erlware_commons to add the bold we want as well.

@tsloughter opinions?