Closed Marc-Pierre-Barbier closed 3 weeks ago
for other people experiencing this issue here is a workaround:
redirecting stderr to a file will disable the use of colorama preventing the crash.
Thanks for your report @Marc-Pierre-Barbier
For reference the code that is printing a very large string is:
def cli_out_write(data, fg=None, bg=None, endline="\n", indentation=0):
"""
Output to be used by formatters to dump information to stdout
"""
fg_ = fg or ''
bg_ = bg or ''
if (fg or bg) and _color_enabled(sys.stdout):
data = f"{' ' * indentation}{fg_}{bg_}{data}{Style.RESET_ALL}{endline}"
else:
data = f"{' ' * indentation}{data}{endline}"
sys.stdout.write(data)
I don't know if there is anything else we can do from Conan side, it doesn't seem so.
Besides the workaround of redirecting the stderr
, you can also explicitly disable colorama by defining env-var NO_COLOR
, so you can still read the stderr on screen as usual.
I am marking this ticket as "invalid", meaning that this isn't really a Conan bug, and there is nothing that we can do from our side at the moment, it seems this can only be fixed from the colorama
side.
I am marking this ticket as "invalid", meaning that this isn't really a Conan bug, and there is nothing that we can do from our side at the moment, it seems this can only be fixed from the
colorama
side.
Colorama doesn't seem active anymore, last commit date from 1 year ago.
What could be done is to find a way to make the conan graph go directly to sys.stdout without going through colorama.
Colorama doesn't seem active anymore, last commit date from 1 year ago.
That is quite unfortunate, I knew it was not very active, but not that it was that stale.
What could be done is to find a way to make the conan graph go directly to sys.stdout without going through colorama.
That is the problem, you see the Conan code above is doing sys.stdout.write(data)
. Conan it is already going directly to sys.stdout
, but colorama intercepts it. So I am not sure how this could be solved without a big (and risky) hack. I am starting to have a look to Rich alternative, but this isn't a small change in the best case it will take time.
I wonder if it only fails for the --format=html
or does it fail for --format=dot
too? and --format=json
?
Just checked about colorama.deinit()
and colorama.reinit()
which I think we can leverage to workaround this at the moment, proposing PR https://github.com/conan-io/conan/pull/17259
https://github.com/conan-io/conan/pull/17259 has been merged, closing this ticket. It will be in next Conan 2.10
Describe the bug
This issue is a copy of the one created on colorama's github: https://github.com/tartley/colorama/issues/396
I was using conan2's command
conan graph info . --format=html > output.html
which generate a html report to a file~the problem is that conan use colorama to print and the massive input led to a recursion limit~
so inside ansitowin32.py i added this piece of code at the begning of write
which wrote a 383KB file called "conankaboum206" and 205 other identical files i will be creating a similar report on conan's side. conankaboum206.txt
here is the looping part of the stacktrace
How to reproduce it
Create a very big tree.
no clue if it's the only requirement but on the colorama page i put the html input which caused the crash. and each iteration was identical so this bug is definitely a colorama bug.
it can be replicated by taking the file 'conankaboum206.txt' and using it in colorama's write