Skip to content

Commit

Permalink
Fix windows no cli crash (#2508)
Browse files Browse the repository at this point in the history
* fix: πŸ› windows no cli build crash
  • Loading branch information
DhariniJeeva authored Oct 3, 2024
1 parent 016ff45 commit 7c2ea87
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ui/desktop/electron-app/src/cli/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const path = require('path');
const { isWindows } = require('../helpers/platform.js');
const isDev = require('electron-is-dev');
const { existsSync } = require('node:fs');
const which = require('which');

const binaryName = isWindows() ? 'boundary.exe' : 'boundary';
const builtInCliPath = isDev
Expand All @@ -20,7 +21,17 @@ const isBuiltInCli = existsSync(builtInCliPath);
* Returns Boundary CLI path if the CLI is built in or the Boundary binary name
* if not, so we assume boundary is available within user $PATH.
*/
const pathBoundary = isBuiltInCli ? builtInCliPath : binaryName;
const pathBoundary = isBuiltInCli
? builtInCliPath
: // On Windows, we need to filter out the path that is within the current working directory.
// This is necessary because the spawn methods may not always find the correct binary path.
// The `which` module returns an array of all available paths for the 'boundary' binary.
// We then filter out the path that is within the current working directory.
isWindows()
? which
.sync(binaryName, { nothrow: true, all: true })
.filter((binary) => !binary.startsWith(process.cwd()))[0]
: binaryName;

module.exports = {
path: pathBoundary,
Expand Down

0 comments on commit 7c2ea87

Please sign in to comment.