Hadolint parser callback never calls called
This seems similar to other issues like https://github.com/mfussenegger/nvim-lint/issues/500, but for some reason I cannot make hadolint work. As in:
I am on the latest hadolint (2.12.0):
$ hadolint -v
Haskell Dockerfile Linter 2.12.0
My Dockerfile has a couple of errors:
$ hadolint -f json - < Dockerfile
[{"code":"DL3008","column":1,"file":"-","level":"warning","line":4,"message":"Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`"},{"code":"DL3015","column":1,"file":"-","level":"info","line":4,"message":"Avoid additional packages by specifying `--no-install-recommends`"},{"code":"DL4006","column":1,"file":"-","level":"warning","line":17,"message":"Set the SHELL option -o pipefail before RUN with a pipe in it. If you are using /bin/sh in an alpine image or if your shell is symlinked to busybox then consider explicitly setting your SHELL to /bin/ash, or disable this check"}]%
Yet, in https://github.com/mfussenegger/nvim-lint/blob/master/lua/lint/linters/hadolint.lua, the parser callback never gets called. The linter does load properly though, i.e. introducing a typo in the config would fail on lint
local severities = {
error = vim.diagnostic.severity.ERROR,
warning = vim.diagnostic.severity.WARN,
info = vim.diagnostic.severity.INFO,
style = vim.diagnostic.severity.HINT,
}
vim.print('this shows')
return {
cmd = "hadolint",
stdin = true,
stream = "stdout",
ignore_exitcode = true,
args = { "-f", "json", "-" },
parser = function(output) <-- this never gets called
vim.print('this never shows')
local findings = vim.json.decode(output)
local diagnostics = {}
for _, finding in pairs(findings or {}) do
table.insert(diagnostics, {
lnum = finding.line - 1,
col = finding.column,
end_lnum = finding.line - 1,
end_col = finding.column,
severity = assert(severities[finding.level], "missing mapping for severity " .. finding.level),
message = finding.message,
source = "hadolint",
code = finding.code,
})
end
return diagnostics
end,
}
In https://github.com/mfussenegger/nvim-lint/blob/master/lua/lint.lua:241:
-
read_startgets called once
if not stream or stream == "stdout" then
vim.print('read_start gets called')
self.stdout:read_start(read_output(cwd, bufnr, parser, publish))
- the
read_outputcallback never gets called
local function read_output(cwd, bufnr, parser, publish_fn)
return function(err, chunk)
vim.print('callback never gets called')
assert(not err, err)
if chunk then
parser.on_chunk(chunk, bufnr)
else
parser.on_done(publish_fn, bufnr, cwd)
end
end
end
Any hint how to debug that further? I tried switching the stream to both. Setting ignore_exitcode to false shows no error. Running hadolint manually with an empty stream shows []. I am on the latest nvim-lint as well, and nvim 0.10.4
Would it work if you set stdin = false ?
I can't reproduce the issue, hadolint (2.12.0) works fine for me.
I have same issue. But in my case, read_output gets called once and parser callback never called.
Others linter like pylint runs fine.
on macOS 15, nvim 0.10.4.
In my test:
On Ubuntu 22.04 + nvim 0.11.0 + hadolint 2.12.0 does not have this issue.
On macOS 15 + nvim 0.11.0 + hadolint 2.12.0 does have this issue. (and none-ls also not working properly with hadolint, so i guess it probably casued by the macOS version of hadolint)