From 4adce3592a18c18ccfe8344bb9d7e6c5d071b8f7 Mon Sep 17 00:00:00 2001 From: Lifei Zhou Date: Sat, 14 Feb 2026 11:32:32 +1100 Subject: [PATCH 1/7] install node in goose dir --- .../src/platform/windows/bin/install-node.cmd | 37 ---------- ui/desktop/src/platform/windows/bin/npx.cmd | 70 ++++++++++++++----- ui/desktop/src/utils/winShims.ts | 2 +- 3 files changed, 55 insertions(+), 54 deletions(-) delete mode 100644 ui/desktop/src/platform/windows/bin/install-node.cmd diff --git a/ui/desktop/src/platform/windows/bin/install-node.cmd b/ui/desktop/src/platform/windows/bin/install-node.cmd deleted file mode 100644 index 26abe9b09b03..000000000000 --- a/ui/desktop/src/platform/windows/bin/install-node.cmd +++ /dev/null @@ -1,37 +0,0 @@ -@echo off -setlocal enabledelayedexpansion - -REM Check if Node.js is installed in Program Files -if exist "C:\Program Files\nodejs\node.exe" ( - echo Node.js found in Program Files - set "NODE_EXE=C:\Program Files\nodejs\node.exe" - goto :found -) - -REM Check if Node.js is installed in Program Files (x86) -if exist "C:\Program Files (x86)\nodejs\node.exe" ( - echo "Node.js found in Program Files (x86)" - set "NODE_EXE=C:\Program Files (x86)\nodejs\node.exe" - goto :found -) - -echo Node.js not found in standard locations, installing... - -REM Download Node.js MSI installer -powershell -Command "& {[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '%1' -OutFile '%TEMP%\node-setup.msi'}" - -REM Install Node.js silently -msiexec /i "%TEMP%\node-setup.msi" /qn - -REM Wait a bit for installation to complete -timeout /t 5 /nobreak - -REM Clean up -del "%TEMP%\node-setup.msi" - -REM Set path to installed Node.js -set "NODE_EXE=C:\Program Files\nodejs\node.exe" - -:found -echo Using Node.js: %NODE_EXE% -exit /b 0 diff --git a/ui/desktop/src/platform/windows/bin/npx.cmd b/ui/desktop/src/platform/windows/bin/npx.cmd index 7c019e5ffe82..65e37a15fc3c 100644 --- a/ui/desktop/src/platform/windows/bin/npx.cmd +++ b/ui/desktop/src/platform/windows/bin/npx.cmd @@ -1,31 +1,69 @@ @ECHO OFF SETLOCAL EnableDelayedExpansion -SET "SCRIPT_DIR=%~dp0" +SET "NODE_VERSION=22.14.0" +SET "GOOSE_NODE_DIR=%LOCALAPPDATA%\Goose\node" -REM Try to find Node.js in standard locations first -if exist "C:\Program Files\nodejs\npx.cmd" ( - "C:\Program Files\nodejs\npx.cmd" %* - exit /b %errorlevel% +REM === Check for previously downloaded portable Node.js === +if exist "%GOOSE_NODE_DIR%\npx.cmd" ( + "%GOOSE_NODE_DIR%\npx.cmd" %* + exit /b !errorlevel! ) -if exist "C:\Program Files (x86)\nodejs\npx.cmd" ( - "C:\Program Files (x86)\nodejs\npx.cmd" %* - exit /b %errorlevel% +REM === Search PATH for npx, skipping ourselves === +for /f "tokens=*" %%i in ('where npx.cmd 2^>nul') do ( + if /i not "%%i"=="%~f0" ( + "%%i" %* + exit /b !errorlevel! + ) ) -REM If Node.js not found, run installer -call "%SCRIPT_DIR%install-node.cmd" "https://nodejs.org/dist/v23.10.0/node-v23.10.0-x64.msi" +REM === Check common locations not always on PATH === +for %%p in ( + "C:\Program Files\nodejs" + "C:\Program Files (x86)\nodejs" +) do ( + if exist "%%~p\npx.cmd" ( + "%%~p\npx.cmd" %* + exit /b !errorlevel! + ) +) + +REM === Check nvm-windows (uses system env vars, may not be on PATH) === +if defined NVM_SYMLINK ( + if exist "!NVM_SYMLINK!\npx.cmd" ( + "!NVM_SYMLINK!\npx.cmd" %* + exit /b !errorlevel! + ) +) + +REM === Download portable Node.js as last resort === +echo [Goose] Node.js not found. Downloading portable Node.js v%NODE_VERSION%... 1>&2 + +SET "NODE_ZIP=%TEMP%\goose-node-%NODE_VERSION%.zip" +SET "NODE_EXTRACT=%TEMP%\goose-node-extract" + +powershell -NoProfile -Command "$ProgressPreference='SilentlyContinue'; try { [Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri 'https://nodejs.org/dist/v%NODE_VERSION%/node-v%NODE_VERSION%-win-x64.zip' -OutFile '%NODE_ZIP%' -UseBasicParsing; Expand-Archive -Path '%NODE_ZIP%' -DestinationPath '%NODE_EXTRACT%' -Force; exit 0 } catch { Write-Error $_.Exception.Message; exit 1 }" if errorlevel 1 ( - echo Failed to install Node.js + echo [Goose] ERROR: Failed to download Node.js. Please install manually from https://nodejs.org/ 1>&2 + del "%NODE_ZIP%" >nul 2>&1 exit /b 1 ) -REM Try using the newly installed Node.js -if exist "C:\Program Files\nodejs\npx.cmd" ( - "C:\Program Files\nodejs\npx.cmd" %* - exit /b %errorlevel% +REM Install to Goose directory +if exist "%GOOSE_NODE_DIR%" rmdir /s /q "%GOOSE_NODE_DIR%" +mkdir "%GOOSE_NODE_DIR%" >nul 2>&1 +xcopy /s /e /q /y "%NODE_EXTRACT%\node-v%NODE_VERSION%-win-x64\*" "%GOOSE_NODE_DIR%\" >nul 2>&1 + +REM Clean up +del "%NODE_ZIP%" >nul 2>&1 +rmdir /s /q "%NODE_EXTRACT%" >nul 2>&1 + +if exist "%GOOSE_NODE_DIR%\npx.cmd" ( + echo [Goose] Node.js v%NODE_VERSION% ready. 1>&2 + "%GOOSE_NODE_DIR%\npx.cmd" %* + exit /b !errorlevel! ) -echo Failed to find npx after Node.js installation +echo [Goose] ERROR: Installation failed. Please install Node.js manually from https://nodejs.org/ 1>&2 exit /b 1 diff --git a/ui/desktop/src/utils/winShims.ts b/ui/desktop/src/utils/winShims.ts index 058591724a16..7b8170dadd21 100644 --- a/ui/desktop/src/utils/winShims.ts +++ b/ui/desktop/src/utils/winShims.ts @@ -21,7 +21,7 @@ export async function ensureWinShims(): Promise { await fs.promises.mkdir(tgtDir, { recursive: true }); // Copy command-line tools, NOT goosed.exe (which should always be used locally) - const shims = ['uvx.exe', 'uv.exe', 'npx.cmd', 'install-node.cmd']; + const shims = ['uvx.exe', 'uv.exe', 'npx.cmd']; await Promise.all( shims.map(async (shim) => { From 81a47057297848ad4b3e913b552868d19cac75e6 Mon Sep 17 00:00:00 2001 From: Lifei Zhou Date: Sat, 14 Feb 2026 11:48:11 +1100 Subject: [PATCH 2/7] testing --- .github/workflows/bundle-desktop-windows.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/bundle-desktop-windows.yml b/.github/workflows/bundle-desktop-windows.yml index e82ab3d5ad4b..7640e9c3661a 100644 --- a/.github/workflows/bundle-desktop-windows.yml +++ b/.github/workflows/bundle-desktop-windows.yml @@ -1,6 +1,7 @@ name: "Bundle Desktop (Windows)" on: + workflow_disptach: workflow_call: inputs: version: From 599a9350e07d93f85e46ea908a559704fc7026d5 Mon Sep 17 00:00:00 2001 From: Lifei Zhou Date: Sat, 14 Feb 2026 11:50:17 +1100 Subject: [PATCH 3/7] fix test spelling --- .github/workflows/bundle-desktop-windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bundle-desktop-windows.yml b/.github/workflows/bundle-desktop-windows.yml index 7640e9c3661a..a657c11af581 100644 --- a/.github/workflows/bundle-desktop-windows.yml +++ b/.github/workflows/bundle-desktop-windows.yml @@ -1,7 +1,7 @@ name: "Bundle Desktop (Windows)" on: - workflow_disptach: + workflow_dispatch: workflow_call: inputs: version: From 0fae2145ecc530d0296fee407f918a4b8355bbbe Mon Sep 17 00:00:00 2001 From: Lifei Zhou Date: Sat, 14 Feb 2026 13:08:30 +1100 Subject: [PATCH 4/7] fixed recurive checking --- ui/desktop/src/platform/windows/bin/npx.cmd | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ui/desktop/src/platform/windows/bin/npx.cmd b/ui/desktop/src/platform/windows/bin/npx.cmd index 65e37a15fc3c..b856200ab5f7 100644 --- a/ui/desktop/src/platform/windows/bin/npx.cmd +++ b/ui/desktop/src/platform/windows/bin/npx.cmd @@ -10,9 +10,9 @@ if exist "%GOOSE_NODE_DIR%\npx.cmd" ( exit /b !errorlevel! ) -REM === Search PATH for npx, skipping ourselves === +REM === Search PATH for a real npx (one that has node.exe alongside it) === for /f "tokens=*" %%i in ('where npx.cmd 2^>nul') do ( - if /i not "%%i"=="%~f0" ( + if exist "%%~dpi\node.exe" ( "%%i" %* exit /b !errorlevel! ) @@ -38,6 +38,13 @@ if defined NVM_SYMLINK ( ) REM === Download portable Node.js as last resort === + +REM Re-check cache (another parallel extension may have just installed it) +if exist "%GOOSE_NODE_DIR%\npx.cmd" ( + "%GOOSE_NODE_DIR%\npx.cmd" %* + exit /b !errorlevel! +) + echo [Goose] Node.js not found. Downloading portable Node.js v%NODE_VERSION%... 1>&2 SET "NODE_ZIP=%TEMP%\goose-node-%NODE_VERSION%.zip" @@ -51,7 +58,6 @@ if errorlevel 1 ( ) REM Install to Goose directory -if exist "%GOOSE_NODE_DIR%" rmdir /s /q "%GOOSE_NODE_DIR%" mkdir "%GOOSE_NODE_DIR%" >nul 2>&1 xcopy /s /e /q /y "%NODE_EXTRACT%\node-v%NODE_VERSION%-win-x64\*" "%GOOSE_NODE_DIR%\" >nul 2>&1 From 4868ba07fdbe860b857d5b08ca38557898dcecc9 Mon Sep 17 00:00:00 2001 From: Lifei Zhou Date: Sat, 14 Feb 2026 13:49:39 +1100 Subject: [PATCH 5/7] added path for downloaded node --- ui/desktop/src/platform/windows/bin/npx.cmd | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/desktop/src/platform/windows/bin/npx.cmd b/ui/desktop/src/platform/windows/bin/npx.cmd index b856200ab5f7..b981e7c45a88 100644 --- a/ui/desktop/src/platform/windows/bin/npx.cmd +++ b/ui/desktop/src/platform/windows/bin/npx.cmd @@ -6,6 +6,7 @@ SET "GOOSE_NODE_DIR=%LOCALAPPDATA%\Goose\node" REM === Check for previously downloaded portable Node.js === if exist "%GOOSE_NODE_DIR%\npx.cmd" ( + SET "PATH=%GOOSE_NODE_DIR%;!PATH!" "%GOOSE_NODE_DIR%\npx.cmd" %* exit /b !errorlevel! ) @@ -41,6 +42,7 @@ REM === Download portable Node.js as last resort === REM Re-check cache (another parallel extension may have just installed it) if exist "%GOOSE_NODE_DIR%\npx.cmd" ( + SET "PATH=%GOOSE_NODE_DIR%;!PATH!" "%GOOSE_NODE_DIR%\npx.cmd" %* exit /b !errorlevel! ) @@ -66,6 +68,7 @@ del "%NODE_ZIP%" >nul 2>&1 rmdir /s /q "%NODE_EXTRACT%" >nul 2>&1 if exist "%GOOSE_NODE_DIR%\npx.cmd" ( + SET "PATH=%GOOSE_NODE_DIR%;!PATH!" echo [Goose] Node.js v%NODE_VERSION% ready. 1>&2 "%GOOSE_NODE_DIR%\npx.cmd" %* exit /b !errorlevel! From f97047c7d1f3088f512c65f4edd31331d3fd0b5a Mon Sep 17 00:00:00 2001 From: Lifei Zhou Date: Sat, 14 Feb 2026 13:52:33 +1100 Subject: [PATCH 6/7] rename --- ui/desktop/src/platform/windows/bin/npx.cmd | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ui/desktop/src/platform/windows/bin/npx.cmd b/ui/desktop/src/platform/windows/bin/npx.cmd index b981e7c45a88..8619bee2c1e2 100644 --- a/ui/desktop/src/platform/windows/bin/npx.cmd +++ b/ui/desktop/src/platform/windows/bin/npx.cmd @@ -4,8 +4,8 @@ SETLOCAL EnableDelayedExpansion SET "NODE_VERSION=22.14.0" SET "GOOSE_NODE_DIR=%LOCALAPPDATA%\Goose\node" -REM === Check for previously downloaded portable Node.js === -if exist "%GOOSE_NODE_DIR%\npx.cmd" ( +REM === Check for previously downloaded portable Node.js (matching version) === +if exist "%GOOSE_NODE_DIR%\node-v%NODE_VERSION%.installed" ( SET "PATH=%GOOSE_NODE_DIR%;!PATH!" "%GOOSE_NODE_DIR%\npx.cmd" %* exit /b !errorlevel! @@ -41,7 +41,7 @@ if defined NVM_SYMLINK ( REM === Download portable Node.js as last resort === REM Re-check cache (another parallel extension may have just installed it) -if exist "%GOOSE_NODE_DIR%\npx.cmd" ( +if exist "%GOOSE_NODE_DIR%\node-v%NODE_VERSION%.installed" ( SET "PATH=%GOOSE_NODE_DIR%;!PATH!" "%GOOSE_NODE_DIR%\npx.cmd" %* exit /b !errorlevel! @@ -68,6 +68,7 @@ del "%NODE_ZIP%" >nul 2>&1 rmdir /s /q "%NODE_EXTRACT%" >nul 2>&1 if exist "%GOOSE_NODE_DIR%\npx.cmd" ( + echo.>"%GOOSE_NODE_DIR%\node-v%NODE_VERSION%.installed" SET "PATH=%GOOSE_NODE_DIR%;!PATH!" echo [Goose] Node.js v%NODE_VERSION% ready. 1>&2 "%GOOSE_NODE_DIR%\npx.cmd" %* From 33498ebe587b4896b4e573a3df6610e84c2b5392 Mon Sep 17 00:00:00 2001 From: Lifei Zhou Date: Tue, 17 Feb 2026 14:17:37 +1100 Subject: [PATCH 7/7] always use node in goose folder --- ui/desktop/src/platform/windows/bin/npx.cmd | 40 ++------------------- 1 file changed, 3 insertions(+), 37 deletions(-) diff --git a/ui/desktop/src/platform/windows/bin/npx.cmd b/ui/desktop/src/platform/windows/bin/npx.cmd index 8619bee2c1e2..c297b146671d 100644 --- a/ui/desktop/src/platform/windows/bin/npx.cmd +++ b/ui/desktop/src/platform/windows/bin/npx.cmd @@ -11,42 +11,7 @@ if exist "%GOOSE_NODE_DIR%\node-v%NODE_VERSION%.installed" ( exit /b !errorlevel! ) -REM === Search PATH for a real npx (one that has node.exe alongside it) === -for /f "tokens=*" %%i in ('where npx.cmd 2^>nul') do ( - if exist "%%~dpi\node.exe" ( - "%%i" %* - exit /b !errorlevel! - ) -) - -REM === Check common locations not always on PATH === -for %%p in ( - "C:\Program Files\nodejs" - "C:\Program Files (x86)\nodejs" -) do ( - if exist "%%~p\npx.cmd" ( - "%%~p\npx.cmd" %* - exit /b !errorlevel! - ) -) - -REM === Check nvm-windows (uses system env vars, may not be on PATH) === -if defined NVM_SYMLINK ( - if exist "!NVM_SYMLINK!\npx.cmd" ( - "!NVM_SYMLINK!\npx.cmd" %* - exit /b !errorlevel! - ) -) - -REM === Download portable Node.js as last resort === - -REM Re-check cache (another parallel extension may have just installed it) -if exist "%GOOSE_NODE_DIR%\node-v%NODE_VERSION%.installed" ( - SET "PATH=%GOOSE_NODE_DIR%;!PATH!" - "%GOOSE_NODE_DIR%\npx.cmd" %* - exit /b !errorlevel! -) - +REM === Download portable Node.js === echo [Goose] Node.js not found. Downloading portable Node.js v%NODE_VERSION%... 1>&2 SET "NODE_ZIP=%TEMP%\goose-node-%NODE_VERSION%.zip" @@ -59,7 +24,8 @@ if errorlevel 1 ( exit /b 1 ) -REM Install to Goose directory +REM Clean previous version and install to Goose directory +rmdir /s /q "%GOOSE_NODE_DIR%" >nul 2>&1 mkdir "%GOOSE_NODE_DIR%" >nul 2>&1 xcopy /s /e /q /y "%NODE_EXTRACT%\node-v%NODE_VERSION%-win-x64\*" "%GOOSE_NODE_DIR%\" >nul 2>&1