Skip to content

Commit c2ea276

Browse files
committed
fix: resolve command to full exec path for Windows PATHEXT
1 parent 37a53a7 commit c2ea276

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)