romkatv / gitstatus

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

Error message when opening second terminal window #430

Closed sultaz closed 2 months ago

sultaz commented 2 months ago

If I open another terminal window and then open a second window, even in tmux I receive the following error message. `[ERROR]: gitstatus failed to initialize.

Zsh log (/private/var/folders/wh/wlh6mcwd5n12gcl8wd07sq5r0000gn/T/gitstatus.POWERLEVEL9K.501.75557.1714782681.1.xtrace.log):

+(anon):7> setopt monitor
+(anon):9> ((  ! _GITSTATUS_STATE_POWERLEVEL9K  ))
+(anon):10> [[ -r /proc/version ]]
+(anon):13> print -rn
+(anon):14> zsystem flock -f lock_fd /private/var/folders/wh/wlh6mcwd5n12gcl8wd07sq5r0000gn/T/gitstatus.POWERLEVEL9K.501.75557.1714782681.1.lock
+(anon):15> [[ 17 == <1-> ]]
+(anon):18> typeset -gi '_GITSTATUS_LOCK_FD_POWERLEVEL9K=lock_fd'
+(anon):20> [[ darwin23.0 == cygwin* ]]
+(anon):41> sysopen -r -o cloexec -u resp_fd /dev/fd/16
+(anon):44> typeset -gi 'GITSTATUS_DAEMON_PID_POWERLEVEL9K=75572'
+(anon):41> _gitstatus_daemon_p9k_
+(anon):46> [[ 19 == <1-> ]]
+_gitstatus_daemon_p9k_:1> local -i pipe_fd
+(anon):47> typeset -gi '_GITSTATUS_RESP_FD_POWERLEVEL9K=resp_fd'
+(anon):48> typeset -gi '_GITSTATUS_STATE_POWERLEVEL9K=1'
+(anon):51> ((  ! async  ))
+(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 10.0000000000 -i 19 'pgid[$#pgid+1]'
+(anon):57> return

Daemon log (/private/var/folders/wh/wlh6mcwd5n12gcl8wd07sq5r0000gn/T/gitstatus.POWERLEVEL9K.501.75557.1714782681.1.daemon.log):

+_gitstatus_daemon_p9k_:3> local pgid=75572
+_gitstatus_daemon_p9k_:4> [[ 75572 == <1-> ]]
+_gitstatus_daemon_p9k_:5> cd -q /
+_gitstatus_daemon_p9k_:90> ((  lock_fd == -1  ))
+_gitstatus_daemon_p9k_:9> trap '' PIPE
+_gitstatus_daemon_p9k_:11> local uname_sm
+_gitstatus_daemon_p9k_:93> zsystem flock -- /private/var/folders/wh/wlh6mcwd5n12gcl8wd07sq5r0000gn/T/gitstatus.POWERLEVEL9K.501.75557.1714782681.1.lock
+_gitstatus_daemon_p9k_:12> uname_sm=+_gitstatus_daemon_p9k_:12> uname -sm
_gitstatus_daemon_p9k_:12: command not found: uname
+_gitstatus_daemon_p9k_:12> uname_sm=''
+_gitstatus_daemon_p9k_:12> return
+_gitstatus_daemon_p9k_:84> local -i ret=127
+_gitstatus_daemon_p9k_:85> zf_rm -f -- /private/var/folders/wh/wlh6mcwd5n12gcl8wd07sq5r0000gn/T/gitstatus.POWERLEVEL9K.501.75557.1714782681.1.lock /private/var/folders/wh/wlh6mcwd5n12gcl8wd07sq5r0000gn/T/gitstatus.POWERLEVEL9K.501.75557.1714782681.1.fifo
+_gitstatus_daemon_p9k_:86> kill -- -75572

System information:

zsh:      5.9
uname -a: Darwin Allen-Air 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:19:22 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T8112 arm64

If you need help, open an issue and attach this whole error message to it:

https://github.com/romkatv/gitstatus/issues/new`
sultaz commented 2 months ago

It was an issue with the p10k theme

romkatv commented 2 months ago
_gitstatus_daemon_p9k_:12: command not found: uname

This is the culprit. Something in your zsh startup files breaks PATH. Try adding these lines at the very top and at the very bottom of .zshrc and see what gets printed when you open a new terminal tab.

print -r -- '===[ TOP ]==='
print -rC1 -- $path
which uname

...

print -r -- '===[ BOTTOM ]==='
print -rC1 -- $path
which uname
sultaz commented 2 months ago

I found the culprit. I was a bonehead. I was setting up a different terminal emulator following someone else's guide and rather then type it out myself I copied and pasted from the guide and didn't realize this was being added to my .zshrc file.

if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" fi

I was already using P10k with no problems and didn't know what had actually been added during the process. The problem disappeared as soon as I commented this part out.

romkatv commented 2 months ago

I'm glad you've found a solution.