fix(server): open stable Zed when a prerelease Zed is first on PATH - #9501
Open
EzraBuild wants to merge 2 commits into
Open
fix(server): open stable Zed when a prerelease Zed is first on PATH#9501EzraBuild wants to merge 2 commits into
EzraBuild wants to merge 2 commits into
Conversation
Zed's stable, preview, and nightly channels each install their own `zed` CLI. The editor launcher took the first `zed` on PATH, so a machine with a prerelease channel earlier on PATH opened Zed Nightly or Zed Preview when the user chose "Zed". Add `resolveCommandPaths` to the shared shell module, which lists every PATH match for a command in order. The launcher uses it for Zed only: prefer the first install whose location does not name a prerelease channel and, when that is not the first on PATH, launch it by absolute path. Single installs and correctly ordered PATHs keep the bare command, so nothing changes for them. No environment or PATH rewriting. Fixes pingdotgg#1978. Model: Claude Fable 5.1. Harness: Claude Code.
Contributor
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — The change is narrowly scoped to correcting Zed executable selection when stable and prerelease installs coexist on PATH. Existing non-Zed launch behavior and normal single-install cases remain unchanged, with focused tests covering the new resolution path. You can add or adjust custom eligibility rules. Learn more. |
The prerelease check searched the full path for "nightly" or "preview", so a stable Zed under a home directory like `C:\Users\preview-user` was treated as prerelease. Check each path component on its own and require it to name both Zed and the channel, which matches `Zed Preview`, `Zed Nightly.app`, and `zed-nightly.app` but not unrelated folders. Model: Claude Fable 5.1. Harness: Claude Code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
Zed's stable, preview, and nightly channels each install their own
zedCLI. The editor launcher inexternalLauncher.tstook the firstzedfound on PATH, so on a machine where a prerelease channel sits earlier on PATH, choosing "Zed" opened Zed Nightly or Zed Preview.packages/shared/src/shell.tsgainsresolveCommandPaths, which lists every PATH match for a command in order, reusing the existing PATHEXT handling and quote stripping. It never fails and is not cached.nightlyorpreview) and, when that install is not the first on PATH, launches it by absolute path. A single install or an already correct PATH order keeps the bare command, so nothing changes for those users.Tests: a launcher test puts a nightly
zed.EXEahead of a stable one on PATH and asserts stable launches by absolute path, then removes stable and asserts the bare command is kept. A shared test coversresolveCommandPathsordering, explicit paths, and an empty PATH.Why
Fixes #1978. The bug reproduces on Windows with Zed 1.18.0 stable and Zed Preview 1.19.0 installed side by side, both at
%LOCALAPPDATA%\Programs\<channel>\bin\zed.exe, with the Previewbinfirst on PATH. Verified by launching through the realExternalLauncherand checking which Zed process received the workspace:binbefore stablebinUI Changes
None.
Checklist
Validation
vp test run apps/server/src/process/externalLauncher.test.ts(23 passed)vp test run packages/shared/src/shell.test.ts(31 passed)vp lintandvp fmt --checkon the four changed filesvp run --filter @t3tools/shared --filter t3 typecheckModel: Claude Fable 5.1. Harness: Claude Code.
Note
Low Risk
Scoped to Zed editor launch resolution with no PATH or env mutation; wrong heuristics could pick the wrong Zed binary on unusual install layouts.
Overview
When several Zed channels each expose a
zedCLI, choosing Zed no longer always uses the first PATH hit (often Preview/Nightly).resolveCommandPathsin shared shell code returns every executable match for a bare command in PATH order (Windows PATHEXT and quoting unchanged); it never fails and returns[]on an empty PATH.resolveZedCommanduses that only for the Zed editor: it picks the first install whose path is not treated as prerelease (isPrereleaseZedPath— a path segment must include bothzedandnightlyorpreview). If that stable binary is not first on PATH, launch uses its absolute path; if stable is already first or only prerelease exists, behavior stays the barezedcommand. Other editors still use first-available resolution. PATH is not rewritten.Tests cover PATH ordering, nightly-only fallback, prerelease path classification, and
resolveCommandPathsedge cases.Reviewed by Cursor Bugbot for commit a36c424. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix
resolveEditorLaunchto prefer stable Zed over prerelease on PATHresolveCommandPathsto shell.ts which returns every matching executable in PATH order instead of only the first matchisPrereleaseZedPathclassifier to externalLauncher.ts that flags a path as prerelease when one component contains both "zed" and "nightly" or "preview"resolveZedCommandwhich scans all PATH matches and selects the first non-prerelease install, spawning it by absolute path when it is not the first matchresolveEditorLaunchnow usesresolveZedCommandfor Zed only; all other command-based editors keep the existing first-match resolverMacroscope summarized a36c424.