jesseduffield/lazygit · error

Command exited with non-zero exit code, but no output

Error message

Command exited with non-zero exit code, but no output

What it means

The final fallback in the streaming runner (cmd_obj_runner.go:323): the command exited non-zero, stderr was empty, ShouldIgnoreEmptyError was false, and stdout was also empty. lazygit has literally nothing to show, so it tells you the command failed silently — you must inspect the exit code path yourself.

Source

Thrown at pkg/commands/oscommands/cmd_obj_runner.go:323

	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 (
	Password CredentialType = iota
	Username
	Passphrase
	PIN
	Token
)

// Whenever we're asked for a password we return a nil channel to tell the
// caller to kill the process.
var failPromptFn = func(CredentialType) <-chan string {

View on GitHub (pinned to c477a2959b)

Solutions

  1. Check the lazygit command log for the exact command line, then run it in a terminal to see its exit code ('$?')
  2. Verify the binary exists in PATH and is executable
  3. Check system logs (dmesg/OOM, sandbox denials) for evidence the process was killed
  4. If this failure mode is acceptable for the command, build the CmdObj with the ignore-empty-error option so it yields nil

Example fix

// before
cmdObj := c.OS().Cmd.New(args) // fails silently => opaque error

// after
cmdObj := c.OS().Cmd.New(args).IgnoreEmptyError() // empty-output failure returns nil
Defensive patterns

Strategy: validation

Validate before calling

// Before wiring an external tool into lazygit, verify it runs and produces output:
func checkToolExists(path string) error {
    _, err := exec.LookPath(path)
    if err != nil {
        return fmt.Errorf("external tool %q not found in PATH", path)
    }
    return nil
}

Try / catch

if err := cmd.Run(); err != nil {
    if err.Error() == "Command exited with non-zero exit code, but no output" {
        // inspect exit status via the command log; likely missing binary or killed process
        return fmt.Errorf("%s failed silently; check PATH and permissions", cmd.ToString())
    }
    return err
}

Prevention

When it happens

Trigger: A streamed command fails with no output on either stream. Common with tools killed by signals, sandboxed commands blocked from writing, or commands that fail fast before printing anything (e.g. missing binary executed via a wrapper).

Common situations: Missing executable in PATH for a configured external tool, command killed by OOM or sandbox policy, Windows path issues launching a tool, exit-code-only failures from strict tools.

Related errors


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