Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Console colors do not always revert back to default #6080

Closed
jcleavel opened this issue Apr 10, 2018 · 11 comments · Fixed by #12601
Closed

Console colors do not always revert back to default #6080

jcleavel opened this issue Apr 10, 2018 · 11 comments · Fixed by #12601
Assignees
Labels
Core CLI core infrastructure Infrastructure needs-triage This is a new issue that needs to be triaged to the appropriate team. Output
Milestone

Comments

@jcleavel
Copy link

The az keyvault certificate show changes the foreground and background console text colors when the requested certificate is not found, but does not revert the colors when the command is complete.
The color change remains in place until $Host.UI.RawUI.ForegroundColor/$Host.UI.RawUI.BackgroundColor is manually reset, or until a new session/host process is created.


Environment summary

Install Method:
MSI

CLI version:

azure-cli (2.0.30)

acr (2.0.22)
acs (2.0.30)
advisor (0.5.0)
appservice (0.1.30)
backup (1.1.0)
batch (3.1.11)
batchai (0.1.6)
billing (0.1.7)
cdn (0.0.13)
cloud (2.0.12)
cognitiveservices (0.1.11)
command-modules-nspkg (2.0.1)
configure (2.0.14)
consumption (0.2.2)
container (0.1.20)
core (2.0.30)
cosmosdb (0.1.19)
dla (0.0.18)
dls (0.0.20)
eventgrid (0.1.11)
eventhubs (0.1.1)
extension (0.0.11)
feedback (2.1.0)
find (0.2.8)
interactive (0.3.18)
iot (0.1.18)
keyvault (2.0.20)
lab (0.0.20)
monitor (0.1.4)
network (2.0.26)
nspkg (3.0.2)
profile (2.0.21)
rdbms (0.2.0)
redis (0.2.11)
reservations (0.1.1)
resource (2.0.26)
role (2.0.21)
servicebus (0.1.1)
servicefabric (0.0.11)
sql (2.0.24)
storage (2.0.30)
vm (2.0.29)

Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'
Extensions directory 'C:\Users\USER_NAME\.azure\cliextensions'

Python (Windows) 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 17:54:52) [MSC v.1900 32 bit (Intel)]

Legal docs and information: aka.ms/AzureCliLegal

OS version:
Windows 10 v1709, Build 16299.309

Shell Type:

powershell.exe


Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      16299  251     
@tjprescott
Copy link
Member

I have seen something like this happen inconsistently in CMD as well.

@tjprescott tjprescott added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Apr 11, 2018
@tjprescott tjprescott changed the title az keyvault certificate show hijacks Powershell console colors when certificate not found Console colors do not always revert back to default Apr 11, 2018
@jurgyy
Copy link
Contributor

jurgyy commented Sep 26, 2019

Any updates? This issue is from a year ago and is currently still a problem in the latest version of az cli in combination with Powershell

@yonzhan yonzhan added this to the Sprint 75 milestone Sep 28, 2019
@yonzhan
Copy link
Collaborator

yonzhan commented Sep 28, 2019

@jiasli please take a look and comment.

@yonzhan
Copy link
Collaborator

yonzhan commented Oct 13, 2019

This is a PowerShell issue. Issue created: PowerShell/PowerShell#10729

@yonzhan yonzhan closed this as completed Oct 13, 2019
@jiasli
Copy link
Member

jiasli commented Oct 15, 2019

This also happens in cmd, which is a colorama issue tartley/colorama#200. Root cause provided by tartley/colorama#200 (comment).

@jiasli jiasli reopened this Oct 15, 2019
@haroldrandom haroldrandom added bug This issue requires a change to an existing behavior in the product in order to be resolved. Output labels Oct 25, 2019
@yonzhan yonzhan closed this as completed Nov 2, 2019
@yonzhan yonzhan modified the milestones: S159, S160 - For Ignite Nov 2, 2019
@abarger-bss
Copy link

abarger-bss commented Nov 24, 2019

Can this issue be left open until the colorama issue is resolved, or until the az cli provides a mitigation? My team encounters this issue almost daily, and it makes the product seem unprofessional. Even if the root cause belongs to another product, the az cli owns some responsibility by selecting the dependency. I would accept an option to disable colors altogether. As it stands I am considering wrapping my PowerShell functions which use the az cli in try/finally blocks to ensure the terminal colors revert to their original values.

@jiasli
Copy link
Member

jiasli commented Dec 2, 2019

Hi @abarger-bss, sure we can reopen this issue. I have created an issue in Knack to allow disabling color. I will work on this to disable colored output.

@jiasli
Copy link
Member

jiasli commented Dec 3, 2019

Hi @abarger-bss, actually even pip is affected by this issue pypa/pip#6354. Given the condition that there is no better python lib for coloring, I have created PR microsoft/knack#171 to allow disabling color.

@yonzhan yonzhan modified the milestones: S165, S166 Feb 15, 2020
@yonzhan yonzhan assigned qianwens and unassigned jiasli Feb 15, 2020
@jsntcy jsntcy removed the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Feb 18, 2020
@qianwens qianwens assigned jiasli and unassigned qianwens Feb 18, 2020
@mgeorgebrown89
Copy link

Just adding that for me, this happens regardless of the command, but any time there is a failure or a warning, all the output from then on turns either red or yellow, including the prompt.

@yonzhan yonzhan modified the milestones: S166, S167 Mar 7, 2020
@yonzhan yonzhan added the needs-triage This is a new issue that needs to be triaged to the appropriate team. label Mar 9, 2020
@jiasli
Copy link
Member

jiasli commented Mar 17, 2020

This issue can be solved after PR #12604 is merged. We are planing to include the change in this release.

@jiasli
Copy link
Member

jiasli commented Jan 20, 2021

This issue has been fixed by microsoft/knack#209 in Azure CLI 2.18.0. Azure CLI can now disable color automatically if stdout is not a TTY. Please update to the latest version and let us know if the issue is solved. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core CLI core infrastructure Infrastructure needs-triage This is a new issue that needs to be triaged to the appropriate team. Output
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants