Lazygit: "panic: close of nil channel" running lazygit in zsh

Created on 25 Jun 2020  路  21Comments  路  Source: jesseduffield/lazygit

Describe the bug
Basically just the title... running lazygit in zsh 5.8 on macOS. It could be something with my go config - I'm a total go newbie.

To Reproduce
Steps to reproduce the behavior:

  1. Install lazygit via homebrew (brew install lazygit)
  2. Run lazygit
  3. Receive the following error:
panic: close of nil channel

goroutine 1 [running]:
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).RunWithSubprocesses(0xc0001984e0, 0x0, 0x0)
        /Users/gary/code/go/src/github.com/jesseduffield/lazygit/pkg/gui/gui.go:382 +0x115
github.com/jesseduffield/lazygit/pkg/app.(*App).Run(0xc00027fc70, 0xc0000d8800, 0x0)
        /Users/gary/code/go/src/github.com/jesseduffield/lazygit/pkg/app/app.go:165 +0x6b
main.main()
        /Users/gary/code/go/src/github.com/jesseduffield/lazygit/main.go:70 +0x7f3

Expected behavior
lazygit should open my repo

Desktop (please complete the following information):
macOS 10.15.5
lazygit 0.20.4

bug

Most helpful comment

@mjarkk @nagy135 Mine ended up being an issue with my $TERM setting- sorry I didn't update the post!

Adding set -g default-terminal "xterm-256color" to .tmux.conf worked 馃檪

All 21 comments

having exactly the same issue ...running on arch, tried lazygit as well as lazygit-git. Title is misleading, it has nothing to do with shell (bash behaves the same at my machine)

just noticed that it only happens inside tmux

@nagy135 I don't think it's a linux specific issue, as the description of the bug describes:

running lazygit in zsh 5.8 on macOS

@garymh or @nagy135 Can you maybe add more information about the environment,
like odd git configurations, git version, are you using ssh keys that require passwords, are you using gpg keys or odd shell variables?

I'm unable to reproduce this issue locally.

So little summary:
it started happening after 50day uptime reboot (so it might be anything there)
happens in any terminal, any shell
happens inside tmux only, yielding exception in first comment
happens on any version I tried on my Arch : lazygit, lazygit-git, also installed by go get

  • git version 2.26.2
  • go version go1.14.3 linux/amd64
  • tmux 3.1b
  • Happens in both sshkey case, also in case where I use login/pass

If you d like to see something else feel free to ask. So far I m clueless ...reboot does not help but is not a really big deal, I m just used to use tmux so its sad to need separate terminal

garymh also seems to be using tmux as described in this reply: https://github.com/jesseduffield/lazygit/issues/631#issuecomment-581726592

Hmmm just installed tmux (apt install tmux) and updated lazygit to the latest (from source) version now when i run lazygit in tmux i still get no errors.

i've tried to run lazygit via my shell (fish) from where i run tmux and inside that i run lazygit.
i've also tried to open lazygit by opening a terminal directly with tmux as start command and then running lazygit.

I'm using:

  • git: 2.27.0
  • tmux: 3.0a
  • fish: 3.1.2

I m pretty sure there are people using lazygit in tmux right now ...question is what is happening on my (and gary's) setup that makes it not work but only in tmux ...if you could point me to some logs or something because this error message gives me zero lead on where to start. So far I feel like trying to get to your versions of tmux and git and i will do that later today. Issue was opened 27 days ago, but because of my long uptime It might be the same issue I think. I also noticed that program kinda works, if I m not in the repo it gives me option to create one or even print its version:

commit=f4718a90, build date=20200722.075433, build source=unknown, version=v0.20.9.f4718a90, os=linux, arch=amd64

Something you could do is send the debug output so we might get a bit closer to finding where this exactly happens because as you point out lazygit does still start.

rm ~/.config/jesseduffield/lazygit/development.log

# in a git repo:
lazygit --debug

cat ~/.config/jesseduffield/lazygit/development.log

Oh if you haven't changed the lazygit config you could also try to reset that:

rm -rf ~/.config/jesseduffield/lazygit

did what you suggested, here is clean output of log after I run lazygit inside any repo:

{"buildDate":"20200722.075433","commit":"f4718a90","debug":true,"level":"info","msg":"language: en","time":"2020-07-22T12:18:47+02:00","version":"v0.20.9.f4718a90"}
{"buildDate":"20200722.075433","command":"git status","commit":"f4718a90","debug":true,"level":"info","msg":"RunCommand","time":"2020-07-22T12:18:47+02:00","version":"v0.20.9.f4718a90"}
{"buildDate":"20200722.075433","command":"git config --get push.default","commit":"f4718a90","debug":true,"level":"info","msg":"RunCommand","time":"2020-07-22T12:18:47+02:00","version":"v0.20.9.f4718a90"}
{"buildDate":"20200722.075433","commit":"f4718a90","debug":true,"level":"error","msg":"error reading git config: exit status 1","time":"2020-07-22T12:18:47+02:00","version":"v0.20.9.f4718a90"}
{"buildDate":"20200722.075433","command":"git status","commit":"f4718a90","debug":true,"level":"info","msg":"RunCommand","time":"2020-07-22T12:18:47+02:00","version":"v0.20.9.f4718a90"}

edit: also removed config files and (just to be sure) reinstalled it from AUR ....same issue :/

@mjarkk @nagy135 Mine ended up being an issue with my $TERM setting- sorry I didn't update the post!

Adding set -g default-terminal "xterm-256color" to .tmux.conf worked 馃檪

Did that, tmux kill-server and it seems to be working ...So to clarify, I probably changed that value to:

set -g default-terminal "tmux-256color"

months ago but didnt kill the server, nor source config (even thou I probably did the second one). For anyone seeing the same error, this is your solution. Thanks for investigation

@garymh and @nagy135 what was the original value of your $TERM ?
We can maybe add a check in lazygit that would return a usable error message if we don't support the contents of $TERM and hint the user to use TERM=xterm-256color

I m currently running kitty terminal, their $TERM is xterm-kitty but mistake i did is I made tmux replace it with tmux-256color (in tmux config) since I saw it somewhere (probably because of some color issues i guess).
I dont feel like messing with those values anymore tho , but some sort of error message saying : "Your $TERM value is not supported" would be very helpfull since that error message gave me zero clues. Question is if it is possible to detect this "in general" or if we need some blacklist/whitelist $TERM solution

This is wired if i try to run xterm with your term variable xterm already returns an error:

$ TERM=xterm-kitty tmux
open terminal failed: missing or unsuitable terminal: xterm-kitty

I would like to say this is just a user error and you would need to know better but after doing a quick google xterm-kitty seems to be a commonly used variable.

Even though i can't launch tmux i can still set the variable inside tmux and directly in my shell but then lazygit doesn't crash nor does it look wired.


Here are my shell variables i'm using:

Note: there are a few things missing here for privacy reasons

COLORTERM=truecolor
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
DEFAULTS_PATH=/usr/share/gconf/pop.default.path
DESKTOP_SESSION=pop
DISPLAY=:1
GDMSESSION=pop
GJS_DEBUG_OUTPUT=stderr
GNOME_SHELL_SESSION_MODE=pop
GNOME_TERMINAL_SCREEN=/org/gnome/Terminal/screen/19cd25bb_45e3_453e_92cb_699f11a4d9c0
GNOME_TERMINAL_SERVICE=:1.739
GOPATH=/home/mark/go
GTK_IM_MODULE=ibus
GTK_MODULES=gail:atk-bridge:appmenu-gtk-module
IM_CONFIG_PHASE=1
INVOCATION_ID=27897d028b804f4f9b53c38fd96c5c13
JOURNAL_STREAM=9:46154
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_ADDRESS=en_US.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_MEASUREMENT=en_US.UTF-8
LC_MONETARY=en_US.UTF-8
LC_NAME=en_US.UTF-8
LC_NUMERIC=en_US.UTF-8
LC_PAPER=en_US.UTF-8
LC_TELEPHONE=en_US.UTF-8
LC_TIME=en_US.UTF-8
OMF_CONFIG=/home/mark/.config/omf
OMF_PATH=/home/mark/.local/share/omf
SHELL=/usr/bin/fish
SHLVL=1
TERM=xterm-kitty
USER=mark
USERNAME=mark
XDG_CONFIG_DIRS=/etc/xdg/xdg-pop:/etc/xdg
XDG_CURRENT_DESKTOP=pop:GNOME
XDG_DATA_DIRS=/usr/share/pop:/home/mark/.local/share/flatpak/exports/share/:/var/lib/flatpak/exports/share/:/usr/local/share/:/usr/share/
XDG_SESSION_CLASS=user
XDG_SESSION_DESKTOP=pop
XDG_SESSION_TYPE=x11
XMODIFIERS=@im=ibus

I dont think xterm-kitty is the problem, kitty was not the issue at all (this behaves the same in my alacritty). Issue is this very line inside tmux config: set -g default-terminal "tmux-256color" ...I saw it recommended in alacritty's issues and I bet if you put it inside ~/.tmux.conf you will have the same exception.

Running tmux inside alacritty using set -g default-terminal "tmux-256color" in the config file the doesn't change anything in lazygit.
It still runs perfectly fine.

But this was the solution right setting $TERM to tmux-256color?
So i guessed the previous $TERM value was wrong unless default-terminal also changes other things beside $TERM and if so is there documentation i can explore to try and find the actual issue?

I m going to be honest, I m kinda lost in those values already ...But since this issue is getting little too long I would just sum up what I noticed about my setup:
If I run lazygit (in any of my two terminals - kitty, alacritty) AND I have tmux setting that changes $TERM inside of tmux to tmux-256color, it crashes. I have no idea why but this is the only thing I m sure of. It is possible that I have some other issue that you are not able to replicate, but I would suggest investigating, if it is possible to detect "crash because of wrong $TERM value". If it is, you could try implementing some gracefull failure with error message. If not, just let it be ....we made issue with answer and that is something you could google in seconds. It would help me a lot week ago :)

Thanks for the information this explains the TERM=xterm-kitty variable,
I didn't get lazygit to crash but when running tmux in the kitty terminal the $TERM changes from xterm-kitty to screen when i'm inside of tmux..
In all my other terminals tmux doesn't accept TERM=xterm-kitty so there is something going on aside from changing the $TERM

I'm personally also lost here so unless @garymh has more information to further debug this i'll leave this for what it is for now.

馃 I'm also using kitty- I had the following that I think I took from a blog post somewhere explaining how to use italics in neovim/tmux:

set -g default-terminal "tmux-256color"
set -ga terminal-overrides ',xterm-kitty:RGB'

Perhaps it's that combination?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

spin6lock picture spin6lock  路  5Comments

jangalinski picture jangalinski  路  4Comments

voigtan picture voigtan  路  4Comments

5minpause picture 5minpause  路  6Comments

JoeKlemmer picture JoeKlemmer  路  3Comments