fix(pack): do not assert non-nil stderr #40544

Problem: On some systems `stderr` can be disabled. This results in not
  usable `vim.pack` since it asserted `stderr` to be non-nil.

Solution: Stop asserting non-nil `stderr`. The downside is that
  potential errors are not shown, but this is intentional since `stderr`
  is disabled on system level.

  Still assert non-nil `stdout` as its output is important for
  `vim.pack` to actually do its job. Disabled `stdout` is not something
  that can work with `vim.pack`.
This commit is contained in:
Evgeni Chasnovski
2026-07-02 12:12:35 -04:00
committed by GitHub
parent f33364a41d
commit 25d33dd12b
+3 -3
View File
@@ -276,16 +276,16 @@ local function git_cmd(cmd, cwd)
local sys_opts = { cwd = cwd, text = true, env = env, clear_env = true }
local out = async.await(3, vim.system, cmd, sys_opts) --- @type vim.SystemCompleted
async.await(1, vim.schedule)
local stderr = vim.nonnil(out.stderr, '')
if out.code ~= 0 then
error(out.stderr)
error(stderr)
end
local stdout, stderr = assert(out.stdout), assert(out.stderr)
if stderr ~= '' then
vim.schedule(function()
vim.notify(stderr:gsub('\n+$', ''), vim.log.levels.WARN)
end)
end
return (stdout:gsub('\n+$', ''))
return (assert(out.stdout):gsub('\n+$', ''))
end
local function parse_semver(x)