Skip to content

bug: Invalid lockfile generated when at least one plugin is cloned with Git's new reftable refs format #2046

@sid-maddy

Description

@sid-maddy

Did you check docs and existing issues?

  • I have read all the lazy.nvim docs
  • I have updated the plugin to the latest version before submitting this issue
  • I have searched the existing issues of lazy.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

v0.11.4

Operating system/version

macOS 15.6.1

Describe the bug

Installing a plugin with git v2.51.0 clones the plugin's repository with the new reftable refs format.
See [ANNOUNCE] Git v2.51.0 for more details.

lazy.nvim installs the plugin, but fails to fetch the logs of the plugin, and more importantly, generates an invalid lockfile (lazy-lock.json) containing only an opening brace ({)

The below error is shown after :Lazy syncing the first time:

~/.local/share/nvim/lazy/lazy.nvim/lua/lazy/manage/lock.lua:29: commit is nil

commit = assert(info.commit, "commit is nil"),

The below error is shown after closing and reopening :Lazy:

~/.local/share/nvim/lazy/lazy.nvim/lua/lazy/manage/task/git.lua:90: branch '.invalid' not found

error(k .. " '" .. v .. "' not found")

Workaround

Manually switch the refs format of the cloned plugin from reftable to the files format.

  1. Navigate to the directory where the plugin is cloned.
  2. Run
git fetch
git refs migrate --ref-format=files

Steps To Reproduce

  1. Update git to v2.51.0 or greater
  2. Add a new plugin to the config
  3. Sync the config (:Lazy sync)

Expected Behavior

lazy.nvim installs the plugin, is able to fetch the logs of the plugin, and generates a valid lockfile (lazy-lock.json).

Repro

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
	spec = {
		{
			"Shatur/neovim-ayu",
			opts = {},
			config = function(_, opts)
				local ayu = require("ayu")

				ayu.setup(opts)
				ayu.colorscheme()
			end,
		},
	},
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingnotstaleMarks an issue or pull request to prevent it from being marked as stalestaleThis issue or PR has been inactive for a while

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions