Skip to content

fix(opencli): diagnose OPENCLI_DAEMON_PORT conflict instead of blaming node - #465

Closed
suyash-lyzr wants to merge 1 commit into
Panniantong:mainfrom
suyash-lyzr:fix/opencli-daemon-port-env-diagnosis
Closed

fix(opencli): diagnose OPENCLI_DAEMON_PORT conflict instead of blaming node#465
suyash-lyzr wants to merge 1 commit into
Panniantong:mainfrom
suyash-lyzr:fix/opencli-daemon-port-env-diagnosis

Conversation

@suyash-lyzr

Copy link
Copy Markdown

Problem

On machines with the OpenCLIApp desktop build, every OpenCLI-backed channel (Reddit / Facebook / Instagram / XiaoHongShu / Bilibili) is reported as broken with a misleading fix:

opencli 命令存在但无法执行(node 环境损坏),重装:npm install -g @jackwener/opencli

The node environment is fine. The real cause: opencli >=1.8 hard-exits with EX_CONFIG (78) the moment OPENCLI_DAEMON_PORT is set — even to the correct default port — and the guard runs before --version, so every probe (including --version) fails. The OpenCLIApp desktop build still injects OPENCLI_DAEMON_PORT=19825 into the CLI's environment, so a fresh macOS app install is effectively dead-on-arrival, and npm install does nothing to fix it.

Fix

Detect the rejection from the probe output and prescribe the actual remedy (unset OPENCLI_DAEMON_PORT), noting node is fine — instead of a useless reinstall.

  • Adds env_conflict to OpenCLIStatus + a dedicated opencli_summary line
  • Correct, actionable hint (unset OPENCLI_DAEMON_PORT) rather than "reinstall node"
  • Regression test; full suite green (197 passed)

Verification

Reproduced live against the real OpenCLIApp shim: exit code 78, output contains OPENCLI_DAEMON_PORT is no longer supported (received 19825). The patched probe now returns env_conflict=True and the summary/hint direct the user to unset OPENCLI_DAEMON_PORT.

🤖 Generated with Claude Code

…g node

opencli >=1.8 hard-exits (EX_CONFIG/78) when OPENCLI_DAEMON_PORT is set,
even to the default port, and the guard runs before --version so every
probe fails. The OpenCLIApp desktop build still injects this var, so a
fresh macOS app install is dead-on-arrival and doctor reported a
misleading 'node broken -> npm reinstall' hint.

Detect the rejection from probe output and prescribe 'unset
OPENCLI_DAEMON_PORT' instead, noting node is fine. Adds env_conflict to
OpenCLIStatus, a dedicated summary line, and a regression test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Panniantong

Copy link
Copy Markdown
Owner

感谢定位 OPENCLI_DAEMON_PORT 环境冲突。main 已在子进程探测中剥离该变量并保留宿主环境,回归测试已覆盖,因此关闭。

@Panniantong Panniantong closed this Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants