question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

azure-cli crash when redirecting output

See original GitHub issue

azure-cli crash when redirecting output to some commands:

$ az --version | head -1
azure-cli                          2.5.1
The command failed with an unexpected error. Here is the traceback:

[Errno 32] Broken pipe
Traceback (most recent call last):
  File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 207, in invoke
    self.show_version()
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/__init__.py", line 108, in show_version
    print(ver_string)
  File "/opt/az/lib/python3.6/site-packages/colorama/ansitowin32.py", line 41, in write
    self.__convertor.write(text)
  File "/opt/az/lib/python3.6/site-packages/colorama/ansitowin32.py", line 162, in write
    self.write_and_convert(text)
  File "/opt/az/lib/python3.6/site-packages/colorama/ansitowin32.py", line 190, in write_and_convert
    self.write_plain_text(text, cursor, len(text))
  File "/opt/az/lib/python3.6/site-packages/colorama/ansitowin32.py", line 196, in write_plain_text
    self.wrapped.flush()
BrokenPipeError: [Errno 32] Broken pipe

To open an issue, please run: 'az feedback'
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
BrokenPipeError: [Errno 32] Broken pipe

$ cat /etc/os-release | head  -1
NAME="Ubuntu"

$ az --version | tail -1
and let us know if you're interested in trying out our newest features: https://aka.ms/CLIUXstudy

Same issue has already been reported previously in https://github.com/Azure/azure-cli/issues/58 and https://github.com/Azure/azure-cli/issues/770, those are now closed but still seeing the issue.

Environment

Linux-4.15.0-1082-azure-x86_64-with-debian-stretch-sid
Python 3.6.5
Installer: DEB

azure-cli 2.5.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
fengzhou-msftcommented, May 9, 2020

The issue is caused by the colorama code for survey link. You can turn off the link with export AZURE_OUTPUT_SHOW_SURVEY_LINK=False or disable the color for all command output with export AZURE_CORE_NO_COLOR=True.

For the purpose of parsing Azure CLI version, we recommend az version, the output is a simple json. az version --query '"azure-cli"' gives you the version "2.5.1" on Linux.

0reactions
jiaslicommented, Mar 11, 2021

I re-thought about this issue today and it is actually a colorama bug with head command (linked above 👆).

Anyway, we no longer init colorama if stdout is not a TTY, so we are good.

Read more comments on GitHub >

github_iconTop Results From Across the Web

powershell redirect error from az cli command - Stack Overflow
Powershell will eat your $null , so azure cli won't redirect. You can also try checking for the db first with az mysql...
Read more >
Analyzing system crashes on non-persistent machines
1. Get notified of server crashes and determine the computer name(s) · 2. Secure the dump file (*.DMP) for further analysis. Redirect the...
Read more >
Telemetry - Visual Studio Code
Crash Reports - Crash reports collect diagnostic information when VS Code crashes and sends it to Microsoft to help understand why the crash...
Read more >
How to Live Tail Docker Logs - Papertrail
Therefore, you won't see any logging or other output from your Docker container. ... Enter the following command in your command-line interface (CLI), ......
Read more >
redirecting to /dev/null - shell script - Unix Stack Exchange
the script will still crash. This is because of using > /dev/null 2>&1 will redirect all your command output (both stdout and stderr...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found