jose-elias-alvarez / null-ls.nvim

Use Neovim as a language server to inject LSP diagnostics, code actions, and more via Lua.
Other
3.62k stars 792 forks source link

"failed to run generator: ...command sqlfluff is not executable" leaves temporary files in tree #1201

Open dmfay opened 1 year ago

dmfay commented 1 year ago

FAQ

Issues

Neovim Version

NVIM v0.8.0-1210-gd367ed9b2

Dev Version?

Operating System

Ubuntu 22.04.1 LTS

Minimal Config

Installed null-ls and then sqlfluff through mason.nvim. I did check out the minimal config; I don't use packer and don't expect there's a config issue here, here's the setup.

  require("null-ls").setup({
    sources = {
      require("null-ls").builtins.diagnostics.sqlfluff.with({
        extra_args = { "--dialect", "postgres" }, -- change to your dialect
      }),
    },
  })

Steps to Reproduce

Open a .sql file without sqlfluff on the PATH.

Reproducibility Check

Expected Behavior

null-ls displays an error message that sqlfluff is not available and does nothing else.

Actual Behavior

null-ls displays an error message that sqlfluff is not available and also leaves a .null-ls_814785_filename.sql (numbers vary) copy of the file in the directory tree.

Yes, this could be fixed by installing sqlfluff, but null-ls probably should clean up after itself :)

Debug Log

[WARN Thu Oct 20 18:02:09 2022] ...he/dein/.cache/init.vim/.dein/lua/null-ls/generators.lua:92: failed to run generator: ...u/.cache/dein/.cache/init.vim/.dein/lua/null-ls/loop.lua:165: command sqlfluff is not executable (make sure it's installed and on your $PATH)

Help

I'll dig into it more if I have time but can't promise anything.

Requirements

jose-elias-alvarez commented 1 year ago

It took me a bit to replicate this because null-ls does indeed clean up the temp file when Neovim exits, but yes, we need to handle this case (and should make sure to also clean up on currently unhandled spawn errors).

For anyone who stumbles on this issue before I get around to fixing it: exiting Neovim will clean up any lingering temp file(s).

keaising commented 1 year ago

I meet the same error msg in selene config, this is my config

null_ls.builtins.diagnostics.selene.with({
    cwd = function(_)
        -- https://github.com/Kampfkarren/selene/issues/339#issuecomment-1191992366
        return vim.fs.dirname(
            vim.fs.find({ "selene.toml" }, { upward = true, path = vim.api.nvim_buf_get_name(0) })[1]
        ) or vim.fn.expand("~/.config/selene/") -- fallback value
    end,
}),

After I add a fallback selene config in ~/.config/selene/ or a specific selene config for project in project directory, the error disappear.

For any one encounter the same error in the future, you can check your source's config first.