remote-control: Session fails on Node.js install (bad option: --sdk-url, nested session error)

Resolved 💬 3 comments Opened Feb 26, 2026 by yesuel1 Closed Mar 1, 2026

Summary

claude remote-control fails to handle incoming remote connections on standard Node.js installations (npm global install). Two bugs occur in sequence:

Environment

  • Claude Code version: 2.1.59
  • Install method: npm global (~/.local/bin/claude)
  • Node.js version: v22.14.0 (/usr/local/bin/node)
  • OS: macOS Darwin 25.2.0
  • Auth: claude.ai (OAuth)

Bug 1: node: bad option: --sdk-url

When a remote client connects, the bridge attempts to spawn a new Claude Code subprocess but passes --sdk-url as a Node.js flag instead of a script argument.

Root cause: In cli.js, the bridge is initialized with execPath: process.execPath, which is the raw Node.js binary path (/usr/local/bin/node). When spawning the session subprocess, the args ["--print", "--sdk-url", <sdkUrl>, ...] are passed directly to node, but since no script path is included, Node.js interprets --sdk-url as one of its own flags and rejects it.

On Bun-bundled installs process.execPath IS the correct executable. But on Node.js installs, the correct exec path is process.argv[1] (the claude wrapper script, which has a #!/usr/bin/env node shebang).

Error output:

Session failed: /usr/local/bin/node: bad option: --sdk-url session_01Xxxxx

Fix:

// In bridge initialization, change:
execPath: process.execPath
// To:
execPath: v9() ? process.execPath : process.argv[1]

Bug 2: Nested session rejected (CLAUDECODE env var)

After fixing Bug 1, the subprocess now launches correctly but immediately exits with:

Error: Claude Code cannot be launched inside another Claude Code session.
Nested sessions share runtime resources and will crash all active sessions.
To bypass this check, unset the CLAUDECODE environment variable.

Root cause: The bridge session subprocess inherits CLAUDECODE from the parent process environment (set because we're running inside an existing Claude Code session). The env override in the spawn call does not unset CLAUDECODE.

Fix: Add CLAUDECODE: undefined to the environment override when spawning the bridge session, alongside the existing CLAUDE_CODE_OAUTH_TOKEN: undefined:

H = {
  ...A.env,
  CLAUDE_CODE_OAUTH_TOKEN: void 0,
  CLAUDECODE: void 0,           // <-- add this
  CLAUDE_CODE_ENVIRONMENT_KIND: "bridge",
  ...
}

Workaround (until fixed)

Run remote-control with CLAUDECODE cleared from the shell:

CLAUDECODE="" claude remote-control

Steps to Reproduce

  1. Install Claude Code via npm (npm install -g @anthropic-ai/claude-code)
  2. Authenticate with claude and accept workspace trust
  3. From inside an existing claude session, run claude remote-control
  4. Connect from another device/browser to the session URL
  5. Observe the bad option: --sdk-url error (Bug 1)
  6. After applying the fix for Bug 1, observe the nested session error (Bug 2)

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗