jesseduffield/lazygit · error

Custom command prompt cannot have both a preset and a comman

Error message

Custom command prompt cannot have both a preset and a command for suggestions. Preset: '%s', Command: '%s'

What it means

Thrown by HandlerCreator.generateFindSuggestionsFunc when a custom command's input prompt in the user's config defines BOTH 'suggestions.preset' and 'suggestions.command'. lazygit cannot decide which suggestion source to use, so it rejects the prompt at load time instead of silently picking one.

Source

Thrown at pkg/gui/services/custom_commands/handler_creator.go:166

	}

	self.c.Prompt(types.PromptOpts{
		Title:               prompt.Title,
		InitialContent:      prompt.InitialValue,
		FindSuggestionsFunc: findSuggestionsFn,
		HandleConfirm: func(str string) error {
			return wrappedF(str)
		},
		AllowEmptyInput:    true,
		PreserveWhitespace: true,
	})

	return nil
}

func (self *HandlerCreator) generateFindSuggestionsFunc(prompt *config.CustomCommandPrompt) (func(string) []*types.Suggestion, error) {
	if prompt.Suggestions.Preset != "" && prompt.Suggestions.Command != "" {
		return nil, fmt.Errorf(
			"Custom command prompt cannot have both a preset and a command for suggestions. Preset: '%s', Command: '%s'",
			prompt.Suggestions.Preset,
			prompt.Suggestions.Command,
		)
	} else if prompt.Suggestions.Preset != "" {
		return self.getPresetSuggestionsFn(prompt.Suggestions.Preset)
	} else if prompt.Suggestions.Command != "" {
		return self.getCommandSuggestionsFn(prompt.Suggestions.Command)
	}

	return nil, nil
}

func (self *HandlerCreator) getCommandSuggestionsFn(command string) (func(string) []*types.Suggestion, error) {
	lines := []*types.Suggestion{}
	err := self.c.OS().Cmd.NewShell(command, self.c.UserConfig().OS.ShellFunctionsFile).RunAndProcessLines(func(line string) (bool, error) {
		lines = append(lines, &types.Suggestion{Value: line, Label: line})
		return false, nil

View on GitHub (pinned to c477a2959b)

Solutions

  1. Open the config file and delete either 'preset' or 'command' from the prompt's suggestions block
  2. Keep 'preset' for built-in sources (files, branches, remotes, remoteBranches, refs, tags) or 'command' for a shell command emitting one suggestion per line — never both

Example fix

# before
prompts:
  - type: input
    title: Branch
    suggestions:
      preset: branches
      command: 'git branch --format=%(refname:short)'

# after
prompts:
  - type: input
    title: Branch
    suggestions:
      preset: branches
Defensive patterns

Strategy: validation

Validate before calling

# yq check before starting lazygit
yq '.customCommands[].prompts[]? | select(.suggestions.preset != null and .suggestions.command != null) | "conflict: " + .title' ~/.config/lazygit/config.yml

Prevention

When it happens

Trigger: A customCommands entry with a prompt block containing both keys, e.g. { type: 'input', title: 'Branch', suggestions: { preset: 'branches', command: 'git branch --format=%(refname:short)' } }. Any such entry causes this error when lazygit builds custom command handlers on startup.

Common situations: Copy-pasting a custom command from documentation and adding a preset while the original already had a command; refactoring a prompt from command-based to preset-based suggestions and forgetting to delete the old key.

Related errors


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