From 604bda445ac48af6871d9259e10038944ea90e06 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 25 Aug 2026 14:15:48 -0400 Subject: [PATCH] test(harness): avoid overlong socket filename #41488 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Test sockets live under `$TMPDIR`, which the harness points at the build dir. On macOS/BSD `sockaddr_un.sun_path` is 104 bytes, and a CI build path plus "nvim.." leaves little room: /Users/runner/work/neovim/neovim/build/Xtest_tmpdir_terminal/nvim.runner/aBcDeF/nvim.12345.0 Solution: Point XDG_RUNTIME_DIR (`stdpath('run')`) at "/tmp/nvim_". 28 bytes: /tmp/nvim_19916/nvim.19919.1 TODO?: - `TEMP_DIR_NAMES` prefers `$TMPDIR` over `/tmp`, so on macOS `stdpath('run')` defaults to the long `/var/folders//<…>/T/` path instead of the short `/tmp` alias. Note: - The 104-byte limit applies to the `bind()` arg, not its "realpath", to, so `/tmp/…` symlinks can be used to workaround the limit. --- test/functional/testterm.lua | 2 ++ test/runner.lua | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/test/functional/testterm.lua b/test/functional/testterm.lua index d672a92a6a..6c1979a9da 100644 --- a/test/functional/testterm.lua +++ b/test/functional/testterm.lua @@ -206,6 +206,8 @@ function M.setup_child_nvim(args, opts) local env = t.shallowcopy(opts.env) or {} env.VIMRUNTIME = env.VIMRUNTIME or os.getenv('VIMRUNTIME') env.NVIM_TEST = env.NVIM_TEST or os.getenv('NVIM_TEST') + -- Child servers need the socket dir set by runner.lua. + env.XDG_RUNTIME_DIR = env.XDG_RUNTIME_DIR or os.getenv('XDG_RUNTIME_DIR') return M.setup_screen(opts.extra_rows, argv, opts.cols, env) end diff --git a/test/runner.lua b/test/runner.lua index d42309bb62..23068a511d 100644 --- a/test/runner.lua +++ b/test/runner.lua @@ -38,6 +38,12 @@ if _G.arg[1] and vim.startswith(_G.arg[1], '-X') then vim.env.XDG_CONFIG_HOME = xdg_dir .. '/config' vim.env.XDG_DATA_HOME = xdg_dir .. '/share' vim.env.XDG_STATE_HOME = xdg_dir .. '/state' + if vim.fn.has('win32') == 0 then + -- Socket dir (stdpath("run")), deliberately NOT in the build dir. sockaddr_un.sun_path is 104 + -- bytes on macOS/BSD, "/…/build/tmp/nvim.." can exceed it. #38623 + vim.env.XDG_RUNTIME_DIR = ('/tmp/nvim_%d'):format(vim.uv.os_getpid()) + vim.fn.mkdir(vim.env.XDG_RUNTIME_DIR, 'p') + end end local root = repo_root()