romkatv / powerlevel10k

A Zsh theme
MIT License
45.26k stars 2.15k forks source link

Gitstatus broken pipe issue #2364

Closed BrianFarnhill closed 1 year ago

BrianFarnhill commented 1 year ago

Hi there,

I'm having some weirdness with the gitstatusd plugin - I think. I've had some issues troubleshooting this but I can seem to repro this repeatedly on my machine. In short, when I run a git fetch the command prompt comes back to me but none of my syntax highlighting is working, and when I press arrow keys I get ^[OA appearing in the console instead of the arrows doing what they should, and it stays that way until I run another command, or I press ctrl+c to kill things and bring me a fresh prompt. After kicking around a lot of things, what I did find is that when I kill off my instances of /Users/{USER}/.cache/gitstatus/gitstatusd-darwin-arm6 that are running (I see two of them on a fresh launch of everything), my git fetch commands come good, and my git status in zsh still appears to be working (I assume there's some sort of fallback here?) and everything seems kinda fine.

When I kill the process I see this output:

gitstatus_query_p9k_:print:68: write error: broken pipe

So I assume there's some weirdness going on under the hood here, but I'm a little stuck for troubleshooting next steps. Any thoughts on how I can narrow this down to understand the problem?

romkatv commented 1 year ago

Can you reproduce this if you disable all plugins and frameworks except for powerlevel10k? Your .zshrc will literally have two lines if you do this.

source ~/.p10k.zsh
source ~/powerlevel10k/powerlevel10k.zsh-theme
BrianFarnhill commented 1 year ago

Not quite - so I get the same behavior in terms of the original issue, but I don't see any instance of the gitstatusd process to kill in order to resolve it

romkatv commented 1 year ago

Everything following "After kicking around a lot of things" in the issue description is a red herring and you can ignore it.

Let's try this. Run the following command:

() {
  emulate -L zsh -o err_return -o xtrace
  command rm -rf -- ~/powerlevel10k
  command git -C ~ clone --depth=1 https://github.com/romkatv/powerlevel10k.git
  local rcs=(~/{.zshenv,.zlogin,.zlogout,.zprofile,.zshrc}(N))
  if (( $#rcs )); then
    command mkdir -p -- ~/zsh-backup
    command mv -f -- $rcs ~/zsh-backup
  fi
  print -r -- 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc
  print -r -- 'POWERLEVEL9K_DISABLE_CONFIGURATION_WIZARD=true' >>~/.zshrc
  builtin cd -q -- ~/powerlevel10k
  builtin exec zsh
}

When it completes, run command git fetch. When that finishes in turn, press the UP arrow key, take a screenshot and post it here.

BrianFarnhill commented 1 year ago

Here's the output - I've redacted out the local user name as [[USER]], the host name as [[HOST]] and the folder name as GIT-REPO, other than that its verbatim from my output

[[USER]]@[[HOST]] GIT-REPO % () {
  emulate -L zsh -o err_return -o xtrace
  command rm -rf -- ~/powerlevel10k
  command git -C ~ clone --depth=1 https://github.com/romkatv/powerlevel10k.git
  local rcs=(~/{.zshenv,.zlogin,.zlogout,.zprofile,.zshrc}(N))
  if (( $#rcs )); then
    command mkdir -p -- ~/zsh-backup
    command mv -f -- $rcs ~/zsh-backup
  fi
  print -r -- 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc
  print -r -- 'POWERLEVEL9K_DISABLE_CONFIGURATION_WIZARD=true' >>~/.zshrc
  builtin cd -q -- ~/powerlevel10k
  builtin exec zsh
}

+(anon):2> rm -rf -- /Users/[[USER]]/powerlevel10k
+(anon):3> git -C /Users/[[USER]] clone '--depth=1' https://github.com/romkatv/powerlevel10k.git
Cloning into 'powerlevel10k'...
remote: Enumerating objects: 92, done.
remote: Counting objects: 100% (92/92), done.
remote: Compressing objects: 100% (75/75), done.
remote: Total 92 (delta 17), reused 72 (delta 13), pack-reused 0
Receiving objects: 100% (92/92), 346.06 KiB | 7.06 MiB/s, done.
Resolving deltas: 100% (17/17), done.
+(anon):4> local rcs=( /Users/[[USER]]/.zprofile /Users/[[USER]]/.zshrc )
+(anon):5> ((  2  ))
+(anon):6> mkdir -p -- /Users/[[USER]]/zsh-backup
+(anon):7> mv -f -- /Users/[[USER]]/.zprofile /Users/[[USER]]/.zshrc /Users/[[USER]]/zsh-backup
+(anon):9> print -r -- 'source ~/powerlevel10k/powerlevel10k.zsh-theme'
+(anon):10> print -r -- 'POWERLEVEL9K_DISABLE_CONFIGURATION_WIZARD=true'
+(anon):11> cd -q -- /Users/[[USER]]/powerlevel10k
+(anon):12> zsh
 [[USER]]@[[HOST]]  ~/powerlevel10k   master  () {                                                                                                                                                                               ✔  1001  20:17:02
  emulate -L zsh -o err_return -o xtrace
  command rm -rf -- ~/powerlevel10k
  command git -C ~ clone --depth=1 https://github.com/romkatv/powerlevel10k.git
  local rcs=(~/{.zshenv,.zlogin,.zlogout,.zprofile,.zshrc}(N))
  if (( $#rcs )); then
    command mkdir -p -- ~/zsh-backup
    command mv -f -- $rcs ~/zsh-backup
  fi
  print -r -- 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc
  print -r -- 'POWERLEVEL9K_DISABLE_CONFIGURATION_WIZARD=true' >>~/.zshrc
  builtin cd -q -- ~/powerlevel10k
  builtin exec zsh
}

For some additional context, in my testing I'm only able to reproduce this against repos that are using SSH against an private server. I can hit multiple repos on the same host and I get the same issue, and so far the testing against HTTPS repos on github doesn't present the same issue. Can you think of anything I should be looking at there to narrow the scope?

romkatv commented 1 year ago

The output you've posted looks as expected. By that I mean it does not demonstrate the existeance of the problem.

I'm only able to reproduce this against repos that are using SSH against an private server.

I appreciate the extra info. Are you 100% sure that powerlevel10k is relevant to your observations of the behavior of git fetch? More specifically, are you sure that the issue is reproducible with the 2-line .zshrc from above and not reproducible with an empty .zshrc?

BrianFarnhill commented 1 year ago

My initial thoughts suggested that gitstatusd was causing me some grief, but if you're sure thats a red herring then this might not be a thing. The issue is definitely present in the two ling config file, I just retested again - but i've also just gone and done some testing in a vanilla bash terminal (setting it up as a new profile in iterm2 - doesn't like its brought anything across in terms of env vars or anything) and I can reproduce it there - so I think you were right, it was a red herring and my issue is indeed elsewhere. Thanks for helping me narrow it down - i'll continue my search elsewhere!

romkatv commented 1 year ago

My initial thoughts suggested that gitstatusd was causing me some grief, but if you're sure thats a red herring then this might not be a thing.

You don't need my word for it given that you've tested it yourself:

i've also just gone and done some testing in a vanilla bash terminal [...] and I can reproduce it there

So your issue has nothing to do with the shell. git fetch hangs, plain and simple.

BrianFarnhill commented 1 year ago

Agreed - thanks for the sanity check