Skip to content

[Bug][Desktop][Windows] Built-in terminal for SSH remote projects always fails: "File not found:" (empty path) — node-pty get_shell_path cannot resolve bare 'ssh' #5345

Done

Description

@bnoij

Environment

  • Kimi Code Desktop 1.4.3 (Windows 11 x64)
  • Remote host added via Settings → SSH: Linux aarch64, OpenSSH server
  • Local project terminals work fine; remote project sessions, file access and the agent all work — only the built-in terminal panel fails

Symptom

Opening a terminal in an SSH remote project always fails with:

Error invoking remote method 'kimi:terminal-create': Error: File not found:

Note the path after the colon is empty.

Repro

  1. Settings → SSH → add a remote host
  2. Create a remote project and open it
  3. Press Ctrl+` to open the terminal
  4. Error above appears, 100% reproducible

Root cause (traced to code)

The main process spawns the remote terminal via node-pty with a bare command name: spawn('ssh', args, ...) (found in the terminal module inside resources/app.asar).

node-pty's native layer PtyStartProcess (src/win/conpty.cc) pre-checks relative paths with path_util::get_shell_path (src/win/path_util.cc, identical in v1.1.0 and main). That lookup searches each PATH directory for the literal file name — it never appends PATHEXT/.exe. On Windows only ssh.exe exists, so the pre-check fails and throws "File not found: " + shellpath where shellpath is empty. The subsequent CreateProcessW would resolve ssh.exe correctly (it appends .exe automatically), but it is never reached. Local terminals pass an absolute path (PathIsRelativeW is false), skipping the check — hence they work.

While working around this, I found two additional defects in the same function that defeat user-side workarounds:

  1. Last PATH entry is silently dropped. The parser loop while ((pos = buffer.find(';')) != npos) only collects segments before a semicolon; the final segment remaining in buffer after the loop is never added to paths. Appending a directory containing an extensionless ssh copy to the end of PATH therefore does not help — the directory is never searched.
  2. CWD branch returns an empty string. if (file_exists(filename)) { return shellpath; } returns the empty shellpath when a file named ssh happens to exist in the process CWD, producing the same empty-path error.

Suggested fix

  • In the desktop app: resolve ssh to an absolute path (e.g. C:\Windows\System32\OpenSSH\ssh.exe) before calling node-pty, or
  • Upstream in node-pty: make get_shell_path honor PATHEXT, fix the last-PATH-entry drop, and return filename (not the empty shellpath) from the CWD branch.

Workaround (verified)

Place an extensionless copy of ssh.exe in a directory that is on PATH and is not the last PATH entry (e.g. C:\Users\<user>\.kimi-code\bin\ssh). The pre-check then succeeds and CreateProcessW launches ssh.exe normally; the remote terminal works immediately, no app restart needed.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions