jesseduffield/lazygit · info
No patch created yet. To start building a patch, use 'space'
Error message
No patch created yet. To start building a patch, use 'space' on a commit file or enter to add specific lines
What it means
Thrown by CustomPatchOptionsMenuAction.Call when the user opens the custom patch options menu but PatchBuilder.Active() is false, i.e. no patch has been started. The menu's operations (apply patch, reset patch, copy to clipboard, etc.) all require an in-progress patch, so lazygit tells you how to start one.
Source
Thrown at pkg/gui/controllers/custom_patch_options_menu_action.go:22
"errors"
"fmt"
"github.com/jesseduffield/generics/set"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/gocui"
"github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers"
"github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/utils"
"github.com/samber/lo"
)
type CustomPatchOptionsMenuAction struct {
c *ControllerCommon
}
func (self *CustomPatchOptionsMenuAction) Call() error {
if !self.c.Git().Patch.PatchBuilder.Active() {
return errors.New(self.c.Tr.NoPatchError)
}
if self.c.Git().Patch.PatchBuilder.IsEmpty() {
return errors.New(self.c.Tr.EmptyPatchError)
}
menuItems := []*types.MenuItem{
{
Label: self.c.Tr.ResetPatch,
Tooltip: self.c.Tr.ResetPatchTooltip,
OnPress: self.c.Helpers().PatchBuilding.Reset,
Keys: menuKey('c'),
},
{
Label: self.c.Tr.ApplyPatch,
Tooltip: self.c.Tr.ApplyPatchTooltip,
OnPress: func() error { return self.handleApplyPatch(false) },
Keys: menuKey('a'),View on GitHub (pinned to c477a2959b)
Solutions
- Select a commit file and press 'space' to add the whole file to the patch, or enter line-selection mode to add specific lines
- Then reopen the custom patch options menu
Defensive patterns
Strategy: validation
Validate before calling
// Only open the patch options menu when a patch exists:
if !patchBuilder.Active() {
return errors.New("start a patch first: space on a commit file, or enter for specific lines")
} Prevention
- Disable the patch-options keybinding when no patch is active
- Offer a 'start patch' hint from the empty-state instead of an error
- Teach users the space-on-commit-file entry point for patch building
When it happens
Trigger: Pressing the custom patch options key (typically '<c-p>' ctrl+p) while in the commits/commit-files view without having added any files or lines to the patch builder with 'space' or line selection.
Common situations: Users who expect the menu to bootstrap patch building, or who reset a patch earlier and press the menu key again out of habit.
Related errors
- Patch is still empty. Add some files or lines to your patch
- Cannot change context while in patch building mode because w
- No config file found
- You have no files to stash
- Cannot change the rename similarity threshold while in patch
AI-assisted analysis of jesseduffield/lazygit@c477a2959b (2026-08-15).
Data as JSON: /api/errors/833c30e33b4e4de7.
Report an issue: GitHub.