jesseduffield/lazygit · error
<dynamic: stderr of failed command>
Error message
<dynamic: stderr of failed command>
What it means
Returned from the streaming command runner in pkg/commands/oscommands/cmd_obj_runner.go:313. After a command run via RunCommandOutputWithInlineStatus-style streaming fails, lazygit checks the captured stderr buffer first; if stderr is non-empty it becomes the error. This prioritizes the most diagnostic channel for failed git commands.
Source
Thrown at pkg/commands/oscommands/cmd_obj_runner.go:313
// so close it to unblock the reader — the pipe is synchronous, so all
// output has already been read by now and nothing is lost.
if !cmdObj.ShouldUsePty() {
if closeErr := handler.close(); closeErr != nil {
self.log.Error(closeErr)
}
}
<-streamingDone
self.log.Infof("%s (%s)", cmdObj.ToString(), time.Since(t))
if err != nil {
if cmdObj.suppressOutputUnlessError {
_, _ = self.guiIO.newCmdWriterFn().Write(combinedOutput.Bytes())
}
errStr := stderr.String()
if errStr != "" {
return errors.New(errStr)
}
if cmdObj.ShouldIgnoreEmptyError() {
return nil
}
stdoutStr := stdout.String()
if stdoutStr != "" {
return errors.New(stdoutStr)
}
return errors.New("Command exited with non-zero exit code, but no output")
}
return nil
}
type CredentialType int
const (View on GitHub (pinned to c477a2959b)
Solutions
- Read the returned error string — it is the exact stderr of the git command
- Correct the underlying git state (commit/divergent branches, credentials, remote config)
- If suppressOutputUnlessError was set, the combined output was already flushed to the UI; check the lazygit command log for the full command line
- For scripted use, run the same git command manually to reproduce
Defensive patterns
Strategy: try-catch
Try / catch
if err := task.Run(func() error {
return self.c.OS().Cmd.New(args).Run()
}); err != nil {
if strings.Contains(err.Error(), "Authentication failed") {
return self.promptForCredentials()
}
return err // err.Error() is the command's stderr
} Prevention
- Treat the error text as the diagnostic source; it is verbatim stderr
- Handle specific failure phrases only as a UX nicety, never for control-critical logic
- Reproduce failed streamed commands in a terminal before changing config
When it happens
Trigger: Running a CmdObj with streamed output (e.g. inline-status tasks like fetch/pull/push/fast-forward) where the process exits non-zero and wrote to stderr. The stderr string is returned verbatim as errors.New(errStr).
Common situations: git pull with merge conflicts signaled on stderr, push rejected (non-fast-forward), ssh authentication prompts failing, credential helper errors during a streamed operation.
Related errors
- <dynamic: stdout of failed command>
- <dynamic: joined stderr of failed piped commands>
- <dynamic: combined stdout/stderr of failed command>
- Command exited with non-zero exit code, but no output
- Git version must be at least %s. Please upgrade your git ver
AI-assisted analysis of jesseduffield/lazygit@c477a2959b (2026-08-15).
Data as JSON: /api/errors/b3fc3997be8495e5.
Report an issue: GitHub.