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

  1. Read the returned error string — it is the exact stderr of the git command
  2. Correct the underlying git state (commit/divergent branches, credentials, remote config)
  3. If suppressOutputUnlessError was set, the combined output was already flushed to the UI; check the lazygit command log for the full command line
  4. 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

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


AI-assisted analysis of jesseduffield/lazygit@c477a2959b (2026-08-15). Data as JSON: /api/errors/b3fc3997be8495e5. Report an issue: GitHub.