From 484a4a56d003cd3d7452904b799f8344fe392745 Mon Sep 17 00:00:00 2001 From: Harivansh Rathi Date: Sun, 22 Feb 2026 11:55:13 -0500 Subject: [PATCH] fix(scraper): pass uv.spawn env as KEY=VALUE list Neovim/libuv spawn expects env as a list of KEY=VALUE strings. Passing the map from vim.fn.environ() can fail process startup with ENOENT, which breaks NDJSON test scraping and surfaces as 'Failed to start scraper process'.\n\nConvert env map to a deterministic list before uv.spawn in the NDJSON scraper path. Co-authored-by: Codex --- lua/cp/scraper.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lua/cp/scraper.lua b/lua/cp/scraper.lua index 21cd697..659983f 100644 --- a/lua/cp/scraper.lua +++ b/lua/cp/scraper.lua @@ -20,6 +20,15 @@ local function syshandle(result) return { success = true, data = data } end +local function spawn_env_list(env_map) + local out = {} + for key, value in pairs(env_map) do + out[#out + 1] = tostring(key) .. '=' .. tostring(value) + end + table.sort(out) + return out +end + ---@param platform string ---@param subcommand string ---@param args string[] @@ -56,7 +65,7 @@ local function run_scraper(platform, subcommand, args, opts) handle = uv.spawn(cmd[1], { args = vim.list_slice(cmd, 2), stdio = { nil, stdout, stderr }, - env = env, + env = spawn_env_list(env), cwd = plugin_path, }, function(code, signal) if buf ~= '' and opts.on_event then