From be61a3435caa0489c9af43cb462814edb585ccf2 Mon Sep 17 00:00:00 2001 From: Daniel Han <23090290+danielhanchen@users.noreply.github.com> Date: Wed, 18 Mar 2026 05:50:35 +0000 Subject: [PATCH] Fix cmake not found on Windows after winget install Two issues fixed: 1. After winget installs cmake, Refresh-Environment may not pick up the new PATH entry (MSI PATH changes sometimes need a new shell). Added a fallback that probes cmake's default install locations (Program Files, LocalAppData) and adds the directory to PATH explicitly if found. 2. If cmake is still unavailable when the llama.cpp build starts (e.g. winget failed silently or PATH was not updated), the build now skips gracefully with a [SKIP] warning instead of crashing with "cmake : The term 'cmake' is not recognized". --- studio/setup.ps1 | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/studio/setup.ps1 b/studio/setup.ps1 index 8ad4009bac..33aeceef65 100644 --- a/studio/setup.ps1 +++ b/studio/setup.ps1 @@ -340,6 +340,25 @@ if (-not $HasCmake) { $HasCmake = $null -ne (Get-Command cmake -ErrorAction SilentlyContinue) } catch { } } + # winget may succeed but cmake isn't on PATH yet (MSI PATH changes need a + # new shell). Try the default install location as a fallback. + if (-not $HasCmake) { + $cmakeDefaults = @( + "$env:ProgramFiles\CMake\bin", + "${env:ProgramFiles(x86)}\CMake\bin", + "$env:LOCALAPPDATA\CMake\bin" + ) + foreach ($d in $cmakeDefaults) { + if (Test-Path (Join-Path $d "cmake.exe")) { + $env:Path = "$d;$env:Path" + $HasCmake = $null -ne (Get-Command cmake -ErrorAction SilentlyContinue) + if ($HasCmake) { + Write-Host " Found cmake at $d (added to PATH)" -ForegroundColor Gray + break + } + } + } + } if ($HasCmake) { Write-Host "[OK] CMake installed" -ForegroundColor Green } else { @@ -991,9 +1010,16 @@ $LlamaCppDir = Join-Path $UnslothHome "llama.cpp" $BuildDir = Join-Path $LlamaCppDir "build" $LlamaServerBin = Join-Path $BuildDir "bin\Release\llama-server.exe" +$HasCmakeForBuild = $null -ne (Get-Command cmake -ErrorAction SilentlyContinue) + if (Test-Path $LlamaServerBin) { Write-Host "" Write-Host "[OK] llama-server already exists at $LlamaServerBin" -ForegroundColor Green +} elseif (-not $HasCmakeForBuild) { + Write-Host "" + Write-Host "[SKIP] llama-server build -- cmake not available" -ForegroundColor Yellow + Write-Host " GGUF inference and export will not be available." -ForegroundColor Yellow + Write-Host " Install CMake from https://cmake.org/download/ and re-run setup." -ForegroundColor Yellow } else { Write-Host "" if ($HasNvidiaSmi) {