lazygit: Lazygit hangs on any custom command

Describe the bug When I call any custom command using : it is stuck on “Press enter to return to lazygit” when I call it from Neovim. However, when I call it directly from the Terminal (kitty) like:

/some/repo
> lazygit

+ /bin/zsh -i -c git fetch origin develop

From github.com:some/repo
 * branch                develop    -> FETCH_HEAD
[1]  + 50708 suspended (tty output)  lazygit

> …/some/repo ✖ TTOU 7s
> fg                                                                                                                                                                                                                                                                                
[1]  + 50708 continued  lazygit

it’s stuck, lazygit doesn’t appear. I can’t do anything, I have to kill the terminal.

Environment

> lazygit --version                                                                                                                                                                                                                                                                 
commit=, build date=, build source=nix, version=0.44.1, os=darwin, arch=arm64, git version=2.46.0
> git --version                                                                                                                                                                                                                                                                    
git version 2.46.0

Additional context

I’m using Nix and I noticed that lazygit calls wrong zsh instance. It should use the first one:

> where zsh                                        
/etc/profiles/per-user/me/zsh
/run/current-system/sw/bin/zsh
/bin/zsh

but it uses the last one. I’m not sure if it matters.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 18 (3 by maintainers)

Commits related to this issue

Most upvoted comments

@hglbrg-sli the same issue occurs when lazygit is called directly from the terminal (not from Neovim)

I’m having the same problem when running shell commands. Keeps hanging in Press enter to continue and doesn’t leave, I have to kill lazygit to be able to leave the screen.

I have been using this method for days. And it works fine for me. I’m not sure if it’s the correct way to fix it, but it works.

diff --git forkSrcPrefix/pkg/commands/oscommands/cmd_obj_builder.go forkDstPrefix/pkg/commands/oscommands/cmd_obj_builder.go
index 3e89ce1029354e8c813801a53c3765c9abefba46..97075768584f0d58644c610f0b1eb280303eef46 100644
--- forkSrcPrefix/pkg/commands/oscommands/cmd_obj_builder.go
+++ forkDstPrefix/pkg/commands/oscommands/cmd_obj_builder.go
@@ -52,6 +52,7 @@ func (self *CmdObjBuilder) NewShell(commandStr string) ICmdObj {
 }
 
 func (self *CmdObjBuilder) NewInteractiveShell(commandStr string) ICmdObj {
+	commandStr += "; exit"
 	quotedCommand := self.quotedCommandString(commandStr)
 	cmdArgs := str.ToArgv(fmt.Sprintf("%s %s %s %s", self.platform.InteractiveShell, self.platform.InteractiveShellArg, self.platform.ShellArg, quotedCommand))
 

CleanShot 2024-11-21 at 22 48 16@2x

@jesseduffield , please consider ship Yam’s solution soon.

Here’s a PR: #4126. Could those affected by the problem please test it? Thanks!

After querying GTP, I got the exit solution. I’ve tried multiple commands and it works well. CleanShot 2024-11-13 at 16 09 09@2x

Can you guys try it out?

run <your command>; exit in lazygit instead.

Has the same issue starting from v0.44.0 downdrade to v0.43.1 solve the problem

Based on your logs it’s suspended. What happens if you run fg after that? In my case it’s not going back to lazygit but it’s freezed

Apologies if this is the same issue, but I’m running into almost exactly the same issue except my terminal (wezterm) is not freezing. Lazygit is simply being killed after running a custom command, and I have to reopen it.

It gets suspended, not killed, you can bring it up with fg.

But yes, same issue.

Apologies if this is the same issue, but I’m running into almost exactly the same issue except my terminal (wezterm) is not freezing. Lazygit is simply being killed after running a custom command, and I have to reopen it.

+ /bin/zsh -i -c git pull

Already up to date.

Press enter to return to lazygit[3]  + 13839 suspended (tty input)  lazygit
~/Documents/myRepo $