t3code icon indicating copy to clipboard operation
t3code copied to clipboard

[Bug]: SSH device host says "Could not connect to this host over SSH" when SSH works but Node is missing from the non-interactive PATH

Open SagePacheco opened this issue 1 month ago • 1 comments

Before submitting

  • [x] I searched existing issues and did not find a duplicate.
  • [x] I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. On a macOS machine, put Node on PATH only in ~/.zprofile (common: many installers write there; zsh is the default shell).
  2. On another environment (here a Windows server), Settings → Devices → Device hosts → add the Mac over SSH.
  3. Open the Device panel or call device_list.

Expected behavior

Either the host works, or the status says what is actually wrong, e.g. "Node isn't on this host's non-interactive SSH PATH (add it to ~/.zshenv)".

Actual behavior

The host shows failed with "Could not connect to this host over SSH." SSH itself works: ssh -o BatchMode=yes user@host from the same Windows machine (same key, Windows OpenSSH) succeeds.

The real error is only in server.trace.ndjson, under SshDeviceHost.probe:

SshCommandError: Node is missing from the non-interactive SSH PATH

zsh does not read ~/.zprofile for non-interactive SSH commands, so the probe sees PATH=/usr/bin:/bin:/usr/sbin:/sbin.

Cause in code: apps/server/src/device/DeviceService.ts maps every error.step === "probe" failure to the generic "Could not connect to this host over SSH." (both the readiness mapping around L255–265 and the agent-tools mapping around L310–323), so the underlying SshCommandError message is dropped.

Impact

Misleading: it sends users to debug SSH keys, firewalls and host keys when the connection is fine. Likely common for Mac device hosts.

Version or commit

0.1.1-nightly.20261016.3218 (Windows server); Mac host on 0.1.1-nightly.20261016.3203.

Environment

Server: Windows 11. Device host: macOS 27.0.1, Xcode 27.1, Apple silicon, zsh default shell, Node installed under ~/.local/node.

Logs or stack traces

SshCommandError: Node is missing from the non-interactive SSH PATH
DeviceHostError: Device host <id> failed while probe.
DeviceHostUnavailableError: Device host <id> is unavailable: Could not connect to this host over SSH.

Workaround

Export the Node PATH in ~/.zshenv on the Mac (read by every zsh, including non-interactive SSH). The host then reported ready, simulators listed, and the Device panel streamed immediately, with no restart needed.

Suggestion: surface the probe error's own message when the SSH connection itself succeeded, and optionally mention ~/.zshenv in the Add host dialog.

SagePacheco avatar Oct 16 '26 20:10 SagePacheco

[!NOTE] Grok responding on behalf of Julius.

Confirmed on main: this is a bug in the error mapping, not in your SSH setup.

SshDeviceHost already checks for this case. Before it runs node, the remote command prints Node is missing from the non-interactive SSH PATH and exits. But DeviceService.ts turns every step === "probe" failure into "Could not connect to this host over SSH.", both in readiness (~L262) and in agent readiness (~L321). The SshCommandError text only shows up in the trace, so a working SSH connection gets reported as a failed one.

Workaround (as you found): export Node's PATH in ~/.zshenv on the Mac. zsh doesn't read ~/.zprofile for non-interactive SSH commands.

Related: #4761 had the same non-interactive PATH root cause for agent CLIs over remote SSH (closed). It isn't a duplicate, because this is the device-host probe and its error message.

Thanks for the precise trace and line references.

juliusmarminge avatar Oct 16 '26 20:10 juliusmarminge