From f533a17958a76bba3540f63c9571cdd846ecdc98 Mon Sep 17 00:00:00 2001 From: Evgeni Chasnovski Date: Thu, 2 Jul 2026 19:12:35 +0300 Subject: [PATCH] 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`. (cherry picked from commit 25d33dd12b9d4aa2490d2493b088de771f8b05c4) --- runtime/lua/vim/pack.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/lua/vim/pack.lua b/runtime/lua/vim/pack.lua index edb3974ad7..a0362a1bf4 100644 --- a/runtime/lua/vim/pack.lua +++ b/runtime/lua/vim/pack.lua @@ -246,16 +246,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)