NemoClaw icon indicating copy to clipboard operation
NemoClaw copied to clipboard

Onboard fails with "unknown listener" when lsof is missing (port free)

Open dacheng-lu opened this issue 4 weeks ago • 1 comments

Environment

  • Arch Linux cloud image (Arch-Linux-x86_64-cloudimg.qcow2, rolling), kernel 7.2.11, 4 vCPU / 8 GiB, QEMU/KVM.
  • Docker 29.9.3 (pacman -S docker), OpenShell 0.0.116.
  • Port 8080 free; no gateway process running.
  • lsof absent; ss and fuser present.

Reproduction

On a fresh Arch host with Docker installed:

command -v lsof                 # no output
ss -ltn 'sport = :8080'         # no listener
export NEMOCLAW_AGENT=hermes NEMOCLAW_NON_INTERACTIVE=1 \
       NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE=1 NEMOCLAW_YES=1 \
       NEMOCLAW_PROVIDER=ollama NEMOCLAW_MODEL=llama3.2:3b
bash install.sh --non-interactive --yes-i-accept-third-party-software

The provider choice is not material; the failure occurs before inference setup.

Actual

At [2/8] Starting OpenShell gateway via managed service…:

Refusing to start a second OpenShell gateway: the gateway port has an unknown
or incompletely observed listener. Inspect port 8080 and stop only its owning
process before retrying.
OpenShell gateway managed service failed to start (OpenShell gateway port
ownership validation failed: Onboarding requested exit 1.); using standalone
fallback.

The managed systemd user unit never starts (disabled, empty user journal). Onboarding later fails at [7/8]:

Failed to start dashboard forward on port 18789: NemoClaw could not prove
OpenShell forward cleanup.

The [7/8] path uses the same listener scan; installing lsof and running onboard --resume completes in 48 s, exit 0.

Control: the same host, after pacman -S lsof, resumes successfully. This was not an A/B run without lsof for [7/8]; the causal link there is inferred from the shared scan and the successful resume.

Cause

src/lib/onboard/docker-driver-gateway-port-listener.ts:133 runs:

result = deps.runCaptureEx(["lsof", "-ti", `:${currentGatewayPort()}`, "-sTCP:LISTEN"]);

complete is false when the scan cannot authoritatively enumerate listeners (ENOENT here), so the port-ownership validation refuses before the unit starts. In v0.0.142 the installer's declared dependency check requires strings (scripts/install.sh:3122); it does not require or install lsof.

scripts/install.sh has an ss/fuser fallback in candidate_gateway_port_is_available(), but that is a different check (is the candidate port free). It is not a drop-in replacement for the ownership scan: ss -p and fuser cannot reliably show other users' processes to an unprivileged process.

Expected

A missing lsof should fail as a missing host prerequisite with an install hint, rather than as an "unknown listener" on a free port. Either:

  • check for lsof before onboarding and print the distro-specific install command (Arch: pacman -S lsof; Debian/Ubuntu: apt install lsof), or
  • add an ownership-scan fallback only where it can actually see the owning process, and otherwise report the missing prerequisite explicitly.

Related

  • #10460 (adjacent: upgrade replaces the gateway binary and leaves an ambiguous port owner; not the same missing-binary case).

I can send a PR for whichever fix maintainers prefer.

dacheng-lu avatar Nov 07 '26 07:11 dacheng-lu

At main 3d893367724b3071be2665d71f4818082c75a0cb, the listener scan still invokes lsof unconditionally. A missing executable produces an incomplete scan. The installer checks strings, but has no lsof prerequisite check.

Would an early prerequisite check with an installation hint be the preferred fix? This would preserve the existing fail-closed behavior for unknown or incompletely observed listeners. I would not treat an unavailable scan as proof that a port is free.

The regression plan would cover missing lsof, an empty successful scan, and incomplete listener visibility. The last case must remain denied. I have verified the source path, not reproduced the reported Arch environment or the later dashboard-forward failure.

If this direction is accepted, could a maintainer provide or adopt a same-repository branch for the contribution? The required reviewed-SDK workflow on main rejects fork PRs, and my upstream role is READ. I have not opened another PR or an implementation branch. The reporter has offered to contribute; I am happy to coordinate rather than duplicate their work.

HOYALIM avatar Nov 09 '26 04:11 HOYALIM