fix(cli): use where on Windows in commandExists helper#944
Open
AdarshJ173 wants to merge 1 commit into
Open
Conversation
Closes RedPlanetHQ#904 - Replace POSIX-only `command -v` with a cross-platform check: use `where` on win32, `command -v` on all other platforms - Apply the same single-line fix to all three setup utilities: local.ts, docker.ts, and railway.ts
Member
|
hey @AdarshJ173 after building did it run in windows ? |
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.
Summary
On Windows,
command -v <cmd>is a POSIX-only shell builtin that does not exist incmd.exe. When Node'schild_process.exec()runs this string on Windows, the shell immediately throws an error — causingcommandExists()to returnfalseeven when the target binary (e.g.docker) is fully installed and onPATH. This makescorebrain setup(local, docker, and railway) completely unusable on Windows, even with a working Docker Desktop install.This PR replaces the hardcoded
command -vwith a cross-platform check:whereonwin32,command -von all other platforms — usingprocess.platform, a value that is always available at runtime with no new imports or dependencies.Fixes #904 —
corebrain setupfails on Windows: "docker not found on PATH" when Docker is installedWhat changed
packages/cli/src/utils/setup/local.tscommandExistsusedawait exec(`command -v ${cmd}`)— fails silently on Windows, causingsetupLocalWebappto throwdocker not found on PATHeven when Docker is installed.`${process.platform === 'win32' ? 'where' : 'command -v'} ${cmd}`— one line, zero new imports.packages/cli/src/utils/setup/docker.tscommand -vpattern copied from local.ts, affects bothdockerandtailscalechecks insetupDockerGateway.packages/cli/src/utils/setup/railway.tscommand -vpattern, affectsrailway,brew, andnpmdetection insetupRailwayGatewayandofferRailwayInstall.Acceptance criteria
corebrain setupno longer throws "docker not found on PATH" on Windows when Docker Desktop is installed anddockeris onPATHcorebrain gateway setup --dockercorrectly detectsdockerandtailscaleon Windowscorebrain gateway setup --railwaycorrectly detectsrailway,brew, andnpmon WindowsHow to test
corebrain setupdockercheck without throwingdockertemporarily out of PATH on Windows — verifycommandExistscorrectly returnsfalseand the error message still displayscommand -vis still used (notwhere)Notes
process.platformis a Node.js built-incommandExistsis a private module-level function, not exportedwherecommand has been available on Windows since XP and is present in all moderncmd.exeenvironmentsprocess.platformreturns'win32'for both 32-bit and 64-bit Windows