Skip to content

fix: add explicit tostring() for thread in string.format() for Lua 5.1 compatibility#1461

Merged
lewis6991 merged 5 commits intomainfrom
copilot/fix-compatibility-non-luajit
Jan 9, 2026
Merged

fix: add explicit tostring() for thread in string.format() for Lua 5.1 compatibility#1461
lewis6991 merged 5 commits intomainfrom
copilot/fix-compatibility-non-luajit

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 9, 2026

The plugin fails on Neovim builds using standard Lua 5.1 (non-LuaJIT) with error: bad argument #1 to 'format' (string expected, got thread) in async.lua:173.

LuaJIT implicitly converts thread objects to strings in string.format(), but standard Lua 5.1 does not.

Changes

  • lua/gitsigns/async.lua:173: Wrap thread object with tostring() before passing to string.format()
-  local thread = ('[%s] '):format(self._thread)
+  local thread = ('[%s] '):format(tostring(self._thread))
Original prompt

This section details on the original issue you should resolve

<issue_title>Compatability broken with non-luajit neovim builds</issue_title>
<issue_description>### Description

Hi,

it seems that this plugins doesnt work anymore with neovim builds without LuaJIT (using Lua 5.1).

Neovim version

NVIM v0.11.3 Build type: RelWithDebInfo Lua 5.1

Operating system and version

Ubuntu 25.04

Expected behavior

Should work.

Actual behavior

Error detected while processing BufReadPost Autocommands for "*":
Error executing lua callback: ...re/nvim/plugged/gitsigns.nvim/lua/gitsigns/async.lua:172: bad argument lewis6991/gitsigns.nvim#1 to 'format' (string expeted, got thread)
stack traceback:
        [C]: in function 'error'
        ...re/nvim/plugged/gitsigns.nvim/lua/gitsigns/async.lua:232: in function '_finish'
        ...re/nvim/plugged/gitsigns.nvim/lua/gitsigns/async.lua:326: in function '_resume'
        ...re/nvim/plugged/gitsigns.nvim/lua/gitsigns/async.lua:522: in function 'attach'
        ...al/share/nvim/plugged/gitsigns.nvim/lua/gitsigns.lua:180: in function <...al/share/nvim/plugged/gitsigns.nvim/lua/gitsigs.lua:170>

Minimal config

for name, url in pairs{
  gitsigns = 'https://github.com/lewis6991/gitsigns.nvim',
  -- ADD OTHER PLUGINS _NECESSARY_ TO REPRODUCE THE ISSUE
} do
  local install_path = vim.fn.fnamemodify('gitsigns_issue/'..name, ':p')
  if vim.fn.isdirectory(install_path) == 0 then
    vim.fn.system { 'git', 'clone', '--depth=1', url, install_path }
  end
  vim.opt.runtimepath:append(install_path)
end

require('gitsigns').setup{
  debug_mode = true, -- You must add this to enable debug messages
  -- ADD GITSIGNS CONFIG THAT IS _NECESSARY_ FOR REPRODUCING THE ISSUE
}

-- ADD INIT.LUA SETTINGS THAT IS _NECESSARY_ FOR REPRODUCING THE ISSUE

Steps to reproduce

  1. Use the minimal config with neovim built without LuaJIT
  2. Open a file
  3. The error above appears

Gitsigns debug messages


Gitsigns cache

```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits January 9, 2026 14:52
Co-authored-by: lewis6991 <7904185+lewis6991@users.noreply.github.com>
Co-authored-by: lewis6991 <7904185+lewis6991@users.noreply.github.com>
Co-authored-by: lewis6991 <7904185+lewis6991@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix compatibility issue with non-LuaJIT Neovim builds fix: add explicit tostring() for thread in string.format() for Lua 5.1 compatibility Jan 9, 2026
Copilot AI requested a review from lewis6991 January 9, 2026 14:55
@lewis6991
Copy link
Copy Markdown
Owner

@copilot undo the changes to .gitignore

Co-authored-by: lewis6991 <7904185+lewis6991@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 9, 2026

@copilot undo the changes to .gitignore

Reverted in ffdc8e4

@lewis6991 lewis6991 marked this pull request as ready for review January 9, 2026 14:59
@lewis6991
Copy link
Copy Markdown
Owner

@copilot commit_lint failed

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 9, 2026

@copilot commit_lint failed

The failing commits are intermediate progress commits: "12bbe9a Initial plan" and "b5cd8ea Update progress: All checks passed".

Since I cannot force push or rebase, these will need to remain as-is. The functional fix commit (eaa45bf) and cleanup commits (79a23bd, ffdc8e4) follow the conventional format correctly.

If needed, these can be squashed during merge to create a single conventional commit.

@lewis6991 lewis6991 merged commit d6482eb into main Jan 9, 2026
7 of 8 checks passed
@lewis6991 lewis6991 deleted the copilot/fix-compatibility-non-luajit branch January 9, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compatability broken with non-luajit neovim builds

2 participants