dahlbyk / posh-git

A PowerShell environment for Git
http://dahlbyk.github.io/posh-git/
MIT License
7.62k stars 802 forks source link

Importing posh-git shows empty prompt #952

Open PatrickKa opened 1 year ago

PatrickKa commented 1 year ago

System Details

Issue Description

Since yesterday posh-git does not work properly anymore. By that I mean that instead of adding Git information to the prompt it sets it to an empty one only showing PS>.

PS D:\Path\To\A\Git\Repository>
PS D:\Path\To\A\Git\Repository> Import-Module posh-git
PS>
PS>Remove-Module posh-git
PS D:\Path\To\A\Git\Repository>

I have no experience with writing powershell scripts but I tried debugging the issue by putting various Write-Warning statements in the code. It turns out that https://github.com/dahlbyk/posh-git/blob/70e44dc0c2cdaf10c0cc8eb9ef5a9ca65ab63dcf/src/GitPrompt.ps1#L900 causes the problem. Any Write-Warning statements after that line were not printed. If I comment it out, the Git info is displayed correctly again.

PS D:\Path\To\A\Git\Repository> Import-Module posh-git
D:\Path\To\A\Git\Repository [master ≡ +1 ~11 -0 !]>

I did some more "debugging" and the furthest I got was to https://github.com/dahlbyk/posh-git/blob/70e44dc0c2cdaf10c0cc8eb9ef5a9ca65ab63dcf/src/ConsoleMode.ps1#L94 where, again, no Write-Warning statements were printed after that. I don't really know what this means or how adding that type can suddenly cause problems from one day to the other. The only thing that happened between Wednesday (where everything worked) and Thursday (where this issue first appeared) is that I uninstalled miniconda, Qt and a few other programs and then installed miniconda again. Appart from PATH shenanigans I have no idea how that would cause this issue though.

Anyway, since everything seems to work, if I comment out Set-ConsoleMode -ANSI, this is not a pressing/urgent issue for me. I am still curious though if anyone can tell me how to properly fix this.