[PR #163] fix(cli): handle missing browser opener gracefully #275

Open
opened 2026-02-15 17:16:37 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/openclaw/clawhub/pull/163
Author: @aronchick
Created: 2/7/2026
Status: 🔄 Open

Base: mainHead: fix/handle-missing-browser-opener


📝 Commits (1)

  • bcbbd92 fix(cli): handle missing browser opener gracefully

📊 Changes

1 file changed (+13 additions, -0 deletions)

View changed files

📝 packages/clawdhub/src/cli/ui.ts (+13 -0)

📄 Description

Problem

On headless Linux servers without xdg-open, clawhub login crashes with:

Error: spawn xdg-open ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:285:19)

This affects:

  • VPS/cloud servers
  • Docker containers
  • CI environments
  • WSL without browser integration

Solution

Catch the ENOENT error and gracefully print the URL for manual copy-paste instead of crashing.

Changes

  • packages/clawdhub/src/cli/ui.ts: Add error handler to openInBrowser()

Testing

Tested on Ubuntu VPS without xdg-open installed:

Before: Crash with ENOENT
After: Prints URL with instructions to open manually

Greptile Overview

Greptile Summary

This PR updates the CLI openInBrowser() helper to handle environments where the platform opener binary (notably xdg-open on headless Linux) is missing. It adds a child.on('error', …) handler and, when the spawn fails with ENOENT, prints the URL and instructions for manual copy/paste instead of crashing.

The change is localized to packages/clawdhub/src/cli/ui.ts and affects the login flow (and any other CLI path that calls openInBrowser) by making browser-opening best-effort rather than a hard failure when the opener executable is not present.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk.
  • The change is small and localized: it adds an 'error' event handler to the spawned opener process and only changes behavior in the specific failure case (missing opener binary, ENOENT) by printing a manual URL instead of crashing. No API surface changes and no control-flow changes outside the error path.
  • No files require special attention

(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/openclaw/clawhub/pull/163 **Author:** [@aronchick](https://github.com/aronchick) **Created:** 2/7/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/handle-missing-browser-opener` --- ### 📝 Commits (1) - [`bcbbd92`](https://github.com/openclaw/clawhub/commit/bcbbd92324eb8705c5c71fca2a9152b2e9788206) fix(cli): handle missing browser opener gracefully ### 📊 Changes **1 file changed** (+13 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/clawdhub/src/cli/ui.ts` (+13 -0) </details> ### 📄 Description ## Problem On headless Linux servers without `xdg-open`, `clawhub login` crashes with: ``` Error: spawn xdg-open ENOENT at ChildProcess._handle.onexit (node:internal/child_process:285:19) ``` This affects: - VPS/cloud servers - Docker containers - CI environments - WSL without browser integration ## Solution Catch the `ENOENT` error and gracefully print the URL for manual copy-paste instead of crashing. ## Changes - `packages/clawdhub/src/cli/ui.ts`: Add error handler to `openInBrowser()` ## Testing Tested on Ubuntu VPS without xdg-open installed: Before: Crash with ENOENT After: Prints URL with instructions to open manually <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR updates the CLI `openInBrowser()` helper to handle environments where the platform opener binary (notably `xdg-open` on headless Linux) is missing. It adds a `child.on('error', …)` handler and, when the spawn fails with `ENOENT`, prints the URL and instructions for manual copy/paste instead of crashing. The change is localized to `packages/clawdhub/src/cli/ui.ts` and affects the login flow (and any other CLI path that calls `openInBrowser`) by making browser-opening best-effort rather than a hard failure when the opener executable is not present. <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk. - The change is small and localized: it adds an 'error' event handler to the spawned opener process and only changes behavior in the specific failure case (missing opener binary, ENOENT) by printing a manual URL instead of crashing. No API surface changes and no control-flow changes outside the error path. - No files require special attention <!-- greptile_other_comments_section --> <sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub> <!-- /greptile_comment --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-15 17:16:37 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: openclaw/clawhub#275