From 46070d8f271078f0ab92bf54db4792b83ac21062 Mon Sep 17 00:00:00 2001 From: Jinwoo Hong <73622457+Jinwoo-H@users.noreply.github.com> Date: Sat, 4 Apr 2026 01:20:09 -0400 Subject: [PATCH] Fix Windows packaged Orca CLI launcher path resolution (#282) --- resources/win32/bin/orca.cmd | 6 +++++- src/main/cli/windows-launcher-asset.test.ts | 13 +++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 src/main/cli/windows-launcher-asset.test.ts diff --git a/resources/win32/bin/orca.cmd b/resources/win32/bin/orca.cmd index bce7919f724..33ad35ad97c 100644 --- a/resources/win32/bin/orca.cmd +++ b/resources/win32/bin/orca.cmd @@ -2,7 +2,11 @@ setlocal set "SCRIPT_DIR=%~dp0" for %%I in ("%SCRIPT_DIR%..") do set "RESOURCES_DIR=%%~fI" -for %%I in ("%RESOURCES_DIR%..") do set "APP_DIR=%%~fI" +REM Why: once %%~fI canonicalizes RESOURCES_DIR it no longer ends with a slash, +REM so Windows batch needs an explicit "\.." segment here. Without it the CLI +REM launcher resolves APP_DIR back to resources/ and `orca open` cannot find +REM Orca.exe on packaged Windows installs. +for %%I in ("%RESOURCES_DIR%\..") do set "APP_DIR=%%~fI" set "ELECTRON=%APP_DIR%\Orca.exe" if not exist "%ELECTRON%" ( diff --git a/src/main/cli/windows-launcher-asset.test.ts b/src/main/cli/windows-launcher-asset.test.ts new file mode 100644 index 00000000000..66de2794de9 --- /dev/null +++ b/src/main/cli/windows-launcher-asset.test.ts @@ -0,0 +1,13 @@ +import { readFileSync } from 'fs' +import { join } from 'path' +import { describe, expect, it } from 'vitest' + +describe('packaged Windows CLI launcher asset', () => { + it('walks from resources/bin back to the app root before locating Orca.exe', () => { + const launcherPath = join(process.cwd(), 'resources', 'win32', 'bin', 'orca.cmd') + const launcher = readFileSync(launcherPath, 'utf8') + + expect(launcher).toContain('for %%I in ("%RESOURCES_DIR%\\..") do set "APP_DIR=%%~fI"') + expect(launcher).not.toContain('for %%I in ("%RESOURCES_DIR%..") do set "APP_DIR=%%~fI"') + }) +})