Skip to content

Commit 9004cbb

Browse files
barrettruthibhagwan
authored andcommitted
fix(manpages): warn when man executable or mandb cache is missing
Problem: when man-db's cache isn't populated (or man isn't installed), `man -k .` exits non-zero with empty stdout. The picker silently shows an empty list with no indication of what went wrong. Solution: check for the man executable upfront and validate that `opts.cmd` produces output before launching the picker. If either check fails, warn the user with an actionable message.
1 parent b2c0603 commit 9004cbb

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

lua/fzf-lua/providers/manpages.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ M.manpages = function(opts)
3939
return
4040
end
4141

42+
if vim.fn.executable("man") ~= 1 then
43+
utils.warn("'man' executable not found.")
44+
return
45+
end
46+
47+
local out = vim.fn.system(opts.cmd)
48+
if vim.v.shell_error ~= 0 or vim.trim(out) == "" then
49+
utils.warn("'man -k' returned no results, try running 'sudo mandb' to populate the cache.")
50+
return
51+
end
52+
4253
opts.fn_transform = function(x)
4354
-- split by first occurrence of ' - ' (spaced hyphen)
4455
local man, desc = x:match("^(.-) %- (.*)$")

0 commit comments

Comments
 (0)