Skip to content

feature: Handle detached HEAD state for dev=true plugins #2140

@msgongora

Description

@msgongora

Did you check the docs?

  • I have read all the lazy.nvim docs

Is your feature request related to a problem? Please describe.

When using dev = true, lazy.nvim calls get_target() on the local plugin directory and asserts that a branch must exist (assert(M.get_branch(plugin))). This crashes with assertion failed! for any local repo in detached HEAD state, which is the default in Jujutsu (jj) colocated repos, where .git/HEAD holds a raw commit SHA instead of a branch ref.

Describe the solution you'd like

For is_local plugins, allow branch to be nil. When no branch can be resolved, fall back to the commit SHA already available from .git/HEAD. This makes local plugin tracking work regardless of VCS workflow, without breaking any existing behavior.

Describe alternatives you've considered

Skipping get_target() entirely for local plugins would remove useful state shown in the :Lazy UI. Emitting a warning and returning nil is less useful and requires more defensive changes in callers.

Additional context

I was fixing another plugin that I use, and after updated the code and tried to clean/update my lazy, I encountered this error I described before:

Failed (1)
    ● opencode-tmux.nvim 2.77ms  opencode.nvim
        ....local/share/nvim/lazy/lazy.nvim/lua/lazy/manage/git.lua:121: assertion failed! 

I have a working implementation that I'll be happy to file as a PR if you are fine with the request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requeststaleThis issue or PR has been inactive for a whilewontfixThis issue will not be fixed or implemented

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions