romkatv / gitstatus

Git status for Bash and Zsh prompt
GNU General Public License v3.0
1.68k stars 106 forks source link

gitstatus failed to initialize (can't open fifo) #364

Closed huyz closed 1 year ago

huyz commented 1 year ago

I've been getting this about 80% of the times after a boot and my iTerm app starts my profile with two windows:

[ERROR]: gitstatus failed to initialize.

  Zsh log (/private/var/folders/cd/80666smx571dkz_nttfhf7dw0000gn/T/gitstatus.POWERLEVEL9K.501.1209.1673411689.1.xtrace.log):

    +(anon):7> setopt monitor
    +(anon):9> ((  ! _GITSTATUS_STATE_POWERLEVEL9K  ))
    +(anon):51> ((  ! async  ))
    +(anon):52> ((  _GITSTATUS_CLIENT_PID_POWERLEVEL9K == sysparams[pid]  ))
    +(anon):54> local pgid
    +(anon):55> ((  0 < 20  ))
    +(anon):56> [[ -t 19 ]]
    +(anon):57> sysread -s 20 -t 5.0000000000 -i 19 'pgid[$#pgid+1]'
    +(anon):55> ((  20 < 20  ))
    +(anon):59> [[ '                1835' == \ #<1-> ]]
    +(anon):60> typeset -gi 'GITSTATUS_DAEMON_PID_POWERLEVEL9K=pgid'
    +(anon):62> sysopen -w -o cloexec -u req_fd -- /private/var/folders/cd/80666smx571dkz_nttfhf7dw0000gn/T/gitstatus.POWERLEVEL9K.501.1209.1673411689.1.fifo
    (anon):sysopen:62: can't open file /private/var/folders/cd/80666smx571dkz_nttfhf7dw0000gn/T/gitstatus.POWERLEVEL9K.501.1209.1673411689.1.fifo: no such file or directory
    +(anon):62> return

  System information:

    zsh:      5.8.1
    uname -a: Darwin hmax 21.6.0 Darwin Kernel Version 21.6.0: Sun Nov  6 23:31:13 PST 2022; root:xnu-8020.240.14~1/RELEASE_ARM64_T6000 arm64

Any idea what could be wrong?

romkatv commented 1 year ago

Something is deleting temporary files while zsh is initializing. This can also sometimes be caused by buggy spyware that some corporate laptops come with.

huyz commented 1 year ago

Hmm, ok I'll keep that in mind. I have a feeling it may take me months or years to figure out which process is doing that, as I run a ton of apps that start at boot. I'll close since I know you like to keep your issues clean ;)

huyz commented 1 year ago

@romkatv is there a chance of race conditions between my several zsh shells starting at the same time, where one gitstatus is nuking the fifo of the other?

romkatv commented 1 year ago

There shouldn't be races in there. You can add GITSTATUS_LOG_LEVEL=DEBUG to zshrc, open a bunch of terminal tabs and then look at xtrace and daemon log files. Their names are available through $GITSTATUS_XTRACE_POWERLEVEL9K and $GITSTATUS_DAEMON_LOG_POWERLEVEL9K in each shell. They both start with $TMPDIR/gitstatus.POWERLEVEL9K.$EUID.$$. where $EUID is effective user id and $$ is the PID of the shell. The latter ensures that files from different terminal tabs have different names.