Skip to content

Commit a25dd58

Browse files
authored
fix: resolve command to full exec path for Windows PATHEXT (#272)
resolves #270 On Windows, `uv.spawn()` does not automatically apply `PATHEXT` resolution. This means when the plugin tries to spawn provider commands like `claude-agent-acp`, it fails on Windows because the actual exectuable is `claude-agent-acp.CMD` but `uv.spawn()` does not know to look for the `.CMD` extension. ## Issue The raw command name from config is being passed directly. ## Solution `vim.fn.exepath()` function provides a cross-platform command resolver, which includes the extension on Windows. ## Risk Low, `vim.fn.exepath()` is available in all supported Neovim versions (`0.11+`). Full paths are accepted by `uv.spawn()`.
1 parent a37f19f commit a25dd58

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

lua/agentic/acp/acp_transport.lua

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ function M.create_stdio_transport(config, callbacks)
7777
function transport:start()
7878
callbacks.on_state_change("connecting")
7979

80+
-- Resolve command to full executable path for Windows OS PATHEXT support
81+
-- vim.fn.exepath handles .CMD, .EXE and .BAT extensions on Windows
82+
local command = vim.fn.exepath(vim.fn.expand(config.command))
83+
if command == "" then
84+
-- if exepath returns empty, the command is not found in PATH
85+
callbacks.on_state_change("error")
86+
error(string.format("Command not found: %s", config.command))
87+
end
88+
8089
local stdin = uv.new_pipe(false)
8190
local stdout = uv.new_pipe(false)
8291
local stderr = uv.new_pipe(false)
@@ -116,7 +125,7 @@ function M.create_stdio_transport(config, callbacks)
116125
end
117126

118127
--- @diagnostic disable-next-line: missing-fields
119-
local handle, pid = uv.spawn(config.command, {
128+
local handle, pid = uv.spawn(command, {
120129
args = args,
121130
env = final_env,
122131
stdio = { stdin, stdout, stderr },
@@ -183,13 +192,22 @@ function M.create_stdio_transport(config, callbacks)
183192
end
184193
end)
185194

186-
Logger.debug("Spawned ACP agent process with PID ", tostring(pid))
187-
188195
if not handle then
196+
stdin:close()
197+
stdout:close()
198+
stderr:close()
199+
189200
callbacks.on_state_change("error")
190-
error("Failed to spawn ACP agent process")
201+
error(
202+
string.format(
203+
"Failed to spawn ACP agent process: %s",
204+
tostring(pid)
205+
)
206+
)
191207
end
192208

209+
Logger.debug("Spawned ACP agent process with PID ", tostring(pid))
210+
193211
self.process = handle
194212
self.pid = tonumber(pid)
195213
self.stdin = stdin

0 commit comments

Comments
 (0)