Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio setup.ps1: install bun only when the frontend is built (#15933)

Daniel Han6cfbb871306c
diff --git a/studio/setup.ps1 b/studio/setup.ps1
index 4cc608ec877..34473d988d8 100644
--- a/studio/setup.ps1
+++ b/studio/setup.ps1
@@ -5489,7 +5489,8 @@ if ($NeedNodeForSetup) {
Remove-Item Env:NODE_PATH -ErrorAction SilentlyContinue
step "node" "$(node -v) | npm $(npm -v) (isolated)"
- if (-not (Test-Path (Join-Path $FrontendDir "package-lock.json")) -and -not (Get-Command bun -ErrorAction SilentlyContinue)) {
+ # Only the frontend build uses bun (as in setup.sh); OXC-only Node (Desktop) skips it.
+ if (-not (Test-Path (Join-Path $FrontendDir "package-lock.json")) -and -not (Get-Command bun -ErrorAction SilentlyContinue) -and $NeedFrontendBuild) {
substep "installing bun (faster frontend package installs)..."
$prevEAP_bun = $ErrorActionPreference
$ErrorActionPreference = "Continue"
diff --git a/tests/studio/test_installers_npm_ci.py b/tests/studio/test_installers_npm_ci.py
index dea5baeedbf..1655ae11a2a 100644
--- a/tests/studio/test_installers_npm_ci.py
+++ b/tests/studio/test_installers_npm_ci.py
@@ -67,6 +67,19 @@ def test_bun_is_not_provisioned_when_npm_ci_will_run():
assert ps1.index(gate) < ps1.index("npm install -g bun")
+def test_bun_is_not_provisioned_without_a_frontend_build():
+ # Node provisioned only for the OXC validator (every Desktop install/update) must not fetch bun.
+ sh = _read("studio/setup.sh")
+ build_branch = sh.index('elif [ "$_NEED_FRONTEND_BUILD" = false ]; then')
+ assert build_branch < sh.index("npm install -g bun")
+ ps1 = _read("studio/setup.ps1")
+ install = ps1.index("npm install -g bun")
+ gate_start = ps1.rindex("if (", 0, install)
+ gate = ps1[gate_start : ps1.index("{", gate_start)]
+ assert "$NeedFrontendBuild" in gate, gate
+ assert ps1.index("$NeedFrontendBuild = $true") < gate_start
+
+
def test_workflows_install_lockfiled_dirs_with_npm_ci():
for name in (
"release-desktop.yml",
diff --git a/tests/studio/test_node_decision.ps1 b/tests/studio/test_node_decision.ps1
index a60367b99e1..89a85e42747 100644
--- a/tests/studio/test_node_decision.ps1
+++ b/tests/studio/test_node_decision.ps1
@@ -137,6 +137,26 @@ Check "global bun install lives in the bundled branch, not the system arm" (
$bundledBranchOffset -lt $globalBunOffset -and $globalBunOffset -lt $systemArmOffset
)
+$bunGate = @($ast.FindAll({ param($n)
+ $n -is [System.Management.Automation.Language.IfStatementAst] -and
+ $n.Clauses[0].Item1.Extent.Text -match 'Get-Command bun' -and $n.Clauses[0].Item2.Extent.Text -match 'npm install -g bun'
+}, $true))
+if ($bunGate.Count -ne 1) { throw "expected one bun install gate, found $($bunGate.Count)" }
+$bunCond = $bunGate[0].Clauses[0].Item1.Extent.Text
+$FrontendDir = Join-Path ([System.IO.Path]::GetTempPath()) ('unsloth-bun-gate-' + [guid]::NewGuid())
+New-Item -ItemType Directory -Path $FrontendDir | Out-Null
+$oldPath = $env:PATH
+try {
+ $env:PATH = $FrontendDir
+ $NeedFrontendBuild = $true
+ Check 'bun fetched for a frontend build without a lockfile' ([bool](Invoke-Expression $bunCond))
+ $NeedFrontendBuild = $false
+ Check 'bun not fetched when Node serves only OXC (Desktop)' (-not (Invoke-Expression $bunCond))
+} finally {
+ $env:PATH = $oldPath
+ Remove-Item -LiteralPath $FrontendDir -Recurse -Force
+}
+
Write-Host ""
if ($failures -gt 0) { Write-Host "$failures check(s) FAILED" -ForegroundColor Red; exit 1 }
Write-Host "All checks passed" -ForegroundColor Green