Skip to content

bug: sql-formatter path not detected correctly on MSYS2 (Windows) #887

Description

@lemonpole

Neovim version (nvim -v)

NVIM v0.12.2

Operating system/version

Windows 11 / MSYS2

Read debugging tips

Add the debug logs

  • I have set log_level = vim.log.levels.DEBUG and pasted the log contents below.

Log file

2026-06-22 14:32:38[ERROR] Formatter 'sql_formatter' error in vim.system: vim/_core/system.lua:326: ENOENT: no such file or directory
2026-06-22 14:36:30[ERROR] Formatter 'sql_formatter' error in vim.system: vim/_core/system.lua:326: ENOENT: no such file or directory
2026-06-22 14:37:54[ERROR] Formatter 'sql_formatter' error in vim.system: vim/_core/system.lua:326: ENOENT: no such file or directory
2026-06-22 14:38:23[ERROR] Formatter 'sql_formatter' error in vim.system: vim/_core/system.lua:326: ENOENT: no such file or directory
2026-06-22 14:42:36[ERROR] Formatter 'sql_formatter' error in vim.system: vim/_core/system.lua:326: ENOENT: no such file or directory
2026-06-22 15:54:05[ERROR] Formatter 'stylua' error: error: could not format from stdin: failed to format from stdin: error parsing:
 - unexpected token `,` (30:31 to 30:32), expected a field
 - unexpected token `:` (32:13 to 32:14), expected `function` after attributes
 - unexpected token `(` (5:25 to 5:26), expected `)` to close function call
 - unexpected token `remove` (32:15 to 32:21), expected arguments after `:`
 - unexpected token `fixed` (32:27 to 32:32), unexpected expression when looking for a statement
 - unexpected token `upstream` (32:33 to 32:41), unexpected expression when looking for a statement
 - unexpected token `sql_formatter` (33:5 to 33:18), unexpected expression when looking for a statement
 - unexpected token `,` (37:6 to 37:7), trailing commas are not allowed
 - unexpected token `}` (38:3 to 38:4), unexpected token, this needs to be a statement
 - unexpected token `,` (42:4 to 42:5), trailing commas are not allowed
 - unexpected token `}` (43:1 to 43:2), unexpected token, this needs to be a statement

Describe the bug

Hello,

I noticed that the sql-formatter.lua is not detecting the path correctly on MSYS2 when installed via node_modules. I believe the issue is here:

Which should instead be similar to how prettier is detected (please refer to workaround below):


Using :ConformInfo you can see it doesn't use the *.cmd executable as expected for Windows machines:

Other formatters:
  clang_format ready (cpp, h, c) C:\msys64\ucrt64\bin\clang-format.EXE
  prettier ready (jsonc, json, markdown, typescript, typescriptreact, javascript, javascriptreact, html, css, yaml) C:
  \msys64\home\lemon\projects\liga\prototype\node_modules\.bin\prettier.cmd
  shfmt unavailable: Command 'shfmt' not found
  sql_formatter ready (sql) C:\msys64\home\lemon\.nvm\versions\node\v24.11.1\bin\sql-formatter
  stylua ready (lua) C:\msys64\usr\bin\stylua.EXE

Workaround

As a workaround (and possible) solution I had to add the following:

sql_formatter = {
      command = require("conform.util").from_node_modules(
        require("conform.fs").is_windows and "sql-formatter.cmd" or "sql-formatter"
      ),
    },

What is the severity of this bug?

minor (annoyance)

Steps To Reproduce

  1. setup nvim on MSYS2.
  2. add sql = { "sql_formatter" }, to conform setup.
  3. open an *.sql file and attempt to format.
  4. error observed in :ConformInfo and in logs.

Expected Behavior

Same behavior as prettier when detecting the executable from node_modules on MSYS2.

Minimal example file

vim.pack.add({
  "https://www.github.com/stevearc/conform.nvim",
})

require("conform").setup({
  formatters_by_ft = {
    sql = { "sql_formatter" },
  },
  format_on_save = {
    timeout_ms = 5000,
    lsp_format = "fallback",
  },
})

Minimal init.lua

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  {
    "stevearc/conform.nvim",
    config = function()
      require("conform").setup({
        log_level = vim.log.levels.DEBUG,
        formatters_by_ft = {
          sql = { "sql_formatter" },
        },
      })
    end,
  },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions