-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LspInfo: "Failed to get version" with bash-language-server #3453
Comments
This seems like a pretty safe change to me. To my knowledge, no command-line tool should output the version to stderr. It just doesn't make sense. diff --git a/lua/lspconfig/health.lua b/lua/lspconfig/health.lua
index 5f40b1a..826d530 100644
--- a/lua/lspconfig/health.lua
+++ b/lua/lspconfig/health.lua
@@ -48,9 +48,7 @@ local function try_get_cmd_output(cmd)
local chanid = vim.fn.jobstart(cmd, {
-- cwd = ?,
stdout_buffered = true,
- stderr_buffered = true,
on_stdout = on_data,
- on_stderr = on_data,
})
local rv = vim.fn.jobwait({ chanid }, 300)
vim.fn.jobstop(chanid) |
Capture stderr is mostly to have something to show on failure. It shouldn't cause the logic to fail. If nvim-lspconfig/lua/lspconfig/health.lua Lines 75 to 78 in dafd61d
Can someone using bash-language-server troubleshoot that logic and find out why it's not captured |
Hmm, it seems to work just fine for me 🤔 Maybe related to a specific version of Neovim? $ nvim --version
NVIM v0.11.0-dev-1228+g9e7b0bcf51-Homebrew
Build type: Release
LuaJIT 2.1.1731601260
Run "nvim -V1 -v" for more info $ bash-language-server --version
5.4.2
(node:97079) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created) (copied the relevant code to its own script) $ cat bug.lua
local function try_get_cmd_output(cmd)
local out = nil
local function on_data(_, data, _)
out = (out or '') .. table.concat(data, '\n')
end
local chanid = vim.fn.jobstart(cmd, {
-- cwd = ?,
stdout_buffered = true,
stderr_buffered = true,
on_stdout = on_data,
on_stderr = on_data,
})
local rv = vim.fn.jobwait({ chanid }, 300)
vim.fn.jobstop(chanid)
return rv[1] == 0 and out or nil
end
local function try_fmt_version(prog)
local all = nil --- Collected output from all attempts.
local tried = '' --- Attempted commands.
for _, v_arg in ipairs { '--version', '-version', 'version', '--help' } do
local cmd = { prog, v_arg }
local out = try_get_cmd_output(cmd)
all = out and ('%s\n%s'):format(all or '', out) or all
local v_line = out and out:match('[^\r\n]*%d+%.[0-9.]+[^\r\n]*') or nil
if v_line then
return ('`%s`'):format(vim.trim(v_line))
end
tried = tried .. ('`%s %s`\n'):format(prog, v_arg)
end
all = all and vim.trim(all:sub(1, 80):gsub('[\r\n]', ' ')) .. '…' or '?'
return ('`%s` (Failed to get version) Tried:\n%s'):format(all, tried)
end
print(try_fmt_version('bash-language-server')) $ nvim -l bug.lua
`5.4.2` |
@yb66 what |
This comment has been minimized.
This comment has been minimized.
Ah, I just noticed the bit about not hanging. Perhaps that could be emulated with a timer? I'll give that a go if you think there's any merit in this approach. Regards, |
The latest stable version is 0.10.2
Because nvim-lspconfig still supports Nvim 0.9
Can you instead try Nvim 0.11 https://github.com/neovim/neovim/releases/tag/nightly to see if the issue is fixed there? |
I seem to be having the same exact issue, but with arduino_language_server. It at all doesn't have a version flag (there's a PR for it arduino/arduino-language-server/issues/196), which results in this in LspInfo (I've replaced full paths with "...").
And this odd log, it was written to stderr, but looks like a "normal level" log to me.
I'm using the latest stable version of everything (meaning, mason, lsp stuff, nvim, this LSP). For Nvim this means 0.10.2 (I also tried the nightly build which I compiled locally today from (neovim/neovim/commit/66bb1e5), but the same exact thing has happened). This has never worked for me, as I'm just getting started with arduino, and just today tried to set everything up. I am also not sure which side is at fault here, but I've found this issue, which seems related. As a side note, all other LSPs I'm using (roslyn, svelte-language-server, and lua_language_server) work as expected. |
I had the same result with v0.10.2. I've also added a line in Regards, |
Description
Hi there,
My bashls wasn't running, so I ran
:LspInfo
inside of Neovim with a shell file open, and got this back as part of the info:I found it's because the recipient is reading STDERR output too, and if there's anything coming through on STDERR then it chokes:
This line is where the server is started:
I replaced:
cmd = { 'bash-language-server', 'start' },
with:
cmd = { 'sh', '-c', 'bash-language-server start 2>/dev/null' },
and it's fixed.
I'd put in a pull request but this is just a workaround and it'd probably be better if STDERR wasn't read (or was handled), but I've no idea about this codebase and any further effects this may have, so this is an FYI.
Regards,
iain
The text was updated successfully, but these errors were encountered: