Skip to content

fix(cli): open the browser on WSL when xdg-open is missing - #71

Merged
hyamero merged 1 commit into
stagingfrom
fix/wsl-open
Nov 13, 2026
Merged

hyamero merged 1 commit into
stagingfrom
fix/wsl-open

Conversation

@hyamero

@hyamero hyamero commented Nov 11, 2026

Copy link
Copy Markdown
Member

Closes #70.

Summary

On WSL, deliver --open wrote the file but never opened it. The opener chose its command from process.platform alone, and WSL reports linux, so it always ran xdg-open. A stock WSL distro doesn't have xdg-open.

On WSL, the opener now tries each of these in turn until one works:

 darwin   open
 win32    cmd /c start "" "<path>"
 linux    xdg-open
+WSL      xdg-open → wslview → explorer.exe "$(wslpath -w <path>)"
  • Detecting WSL: WSL_DISTRO_NAME or WSL_INTEROP is set, or /proc/version contains microsoft.
  • When to move on: after any failure, not only when an opener is missing. If xdg-open is installed but has no Linux browser to open, it fails and explorer.exe still gets the file.
  • explorer.exe: it exits with 1 even when it opened the file, so its exit code is ignored.
  • When nothing works: the warning names each opener and why it failed, e.g. xdg-open not found; wslview not found; explorer.exe not found.

Evidence

  • Unit tests cover the WSL order and isWsl reading the environment variables. The existing darwin, linux and win32 tests now expect a list of openers. The CLI suites pass, 24 of 24, and bun run typecheck is clean.
  • I faked WSL on macOS by forcing the platform to linux, setting WSL_DISTRO_NAME, and putting stub commands on PATH:
    • Only explorer.exe present, exiting with 1: the result is success. explorer.exe received the absolute path from wslpath -w.
    • wslview present: wslview opens the file and explorer.exe isn't run.
    • Nothing present: the warning reads xdg-open not found; wslview not found; explorer.exe not found.
  • Not tried on real WSL yet.

Merge Danger

Door: two-way

Blast Radius: cli-open-on-linux

Only --open on Linux changes, and outside WSL it still runs xdg-open alone.

@vercel

vercel Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
stackmap-site Skipped Skipped Nov 11, 2026 9:49am UTC

@hyamero
hyamero merged commit 7e0b717 into staging Nov 13, 2026
8 checks passed
@hyamero
hyamero deleted the fix/wsl-open branch November 13, 2026 15:15
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.6.2-rc.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.6.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

This branch was previously deployed

1 inactive deployment
Preview — 5b470af1 Deployed Nov 11, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant