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.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
ci: enforce npm ci on Studio install paths (follow-up to #5604) (#5616)
Daniel Hanfbccb937c32e
diff --git a/.github/workflows/desktop-app-clean-machine-ci.yml b/.github/workflows/desktop-app-clean-machine-ci.ymlindex 99fce5a7cf0..9aa11c702c3 100644--- a/.github/workflows/desktop-app-clean-machine-ci.yml+++ b/.github/workflows/desktop-app-clean-machine-ci.yml@@ -697,7 +697,7 @@ jobs:run: python3 scripts/lockfile_supply_chain_audit.py- name: Install pinned Tauri CLI- run: npm install --save-dev --prefix studio @tauri-apps/[email protected] --no-fund --no-audit+ run: npm ci --prefix studio --no-fund --no-audit- name: Install frontend dependenciesworking-directory: studio/frontenddiff --git a/.github/workflows/release-desktop.yml b/.github/workflows/release-desktop.ymlindex 507c3893d6a..c308523515b 100644--- a/.github/workflows/release-desktop.yml+++ b/.github/workflows/release-desktop.yml@@ -598,7 +598,7 @@ jobs:- name: Lockfile supply-chain audit (pre-install scan)shell: bash- # Must run BEFORE any `npm install`. This job has+ # Must run BEFORE any `npm ci`. This job has# ``contents: write`` (release upload), so a compromised# lockfile that runs a malicious postinstall script during the# Tauri CLI install or frontend install below could publish@@ -613,7 +613,7 @@ jobs:# defence against the npm postinstall-dropper class -- it fires# BEFORE any tarball runs, on the injection pattern itself# rather than an advisory-DB lookup.- run: npm install --save-dev --prefix studio @tauri-apps/[email protected] --no-fund --no-audit+ run: npm ci --prefix studio --no-fund --no-audit- name: Verify pinned Tauri CLIshell: bash@@ -724,7 +724,7 @@ jobs:# against the npm postinstall-dropper class -- it fires BEFORE any# tarball runs, on the injection pattern itself rather than an# advisory-DB lookup.- run: npm install --no-fund --no-audit+ run: npm ci --no-fund --no-audit# ── Rust ──- name: Install Rust stablediff --git a/.github/workflows/security-audit.yml b/.github/workflows/security-audit.ymlindex cd33b7743b9..1d6d155ebec 100644--- a/.github/workflows/security-audit.yml+++ b/.github/workflows/security-audit.yml@@ -397,7 +397,7 @@ jobs:{echo "## Lockfile supply-chain audit"echo- echo "Scanned: studio/frontend/package-lock.json + studio/src-tauri/Cargo.lock"+ echo "Scanned: studio/frontend/package-lock.json + studio/backend/core/data_recipe/oxc-validator/package-lock.json + studio/package-lock.json + studio/src-tauri/Cargo.lock"echoecho "No structural anomalies or known IOC strings."} >> "$GITHUB_STEP_SUMMARY"@@ -426,6 +426,23 @@ jobs:echo '```'} >> "$GITHUB_STEP_SUMMARY"+ - name: npm audit (oxc-validator runtime + Tauri CLI holder)+ continue-on-error: true+ run: |+ set +e+ for pair in oxc:studio/backend/core/data_recipe/oxc-validator tauri-cli:studio; do+ name="${pair%%:*}"; dir="${pair#*:}"+ (cd "$dir" && npm audit --audit-level=high) | tee "logs-npm-audit-$name.txt"+ (cd "$dir" && npm audit --json) > "logs-npm-audit-$name.json" || true+ {+ echo "## npm audit ($dir)"+ echo+ echo '```'+ tail -200 "logs-npm-audit-$name.txt"+ echo '```'+ } >> "$GITHUB_STEP_SUMMARY"+ done+# ─────────────────────────────────────────────────────────────# cargo: Unsloth Tauri shell# ─────────────────────────────────────────────────────────────@@ -494,6 +511,8 @@ jobs:else/tmp/osv-scanner scan source \--lockfile=studio/frontend/package-lock.json \+ --lockfile=studio/backend/core/data_recipe/oxc-validator/package-lock.json \+ --lockfile=studio/package-lock.json \--lockfile=studio/src-tauri/Cargo.lock \--lockfile=requirements.txt:audit-reqs/unsloth-deps.txt \--lockfile=requirements.txt:audit-reqs/audio-torch210.txt \@@ -789,6 +808,8 @@ jobs:logs-pip-audit.txtlogs-npm-audit.txtlogs-npm-audit.json+ logs-npm-audit-*.txt+ logs-npm-audit-*.jsonlogs-cargo-audit.txtlogs-osv-scanner.txtlogs-semgrep.txt@@ -1231,40 +1252,42 @@ jobs:# the retry only re-attempts the registry fetch, it never relaxes# that flag or the package-lock integrity check npm ci enforces.retry 5 npm ci --ignore-scripts+ (cd ../backend/core/data_recipe/oxc-validator && retry 5 npm ci --ignore-scripts)+ (cd .. && retry 5 npm ci --ignore-scripts)- name: npm audit signatures (informational)# Surfaces unsigned / mis-signed packages from the npm# transparency log. continue-on-error during baseline-build# phase; promote to hard gate once the lockfile is fully# signed (most major maintainers signed by mid-2025).- working-directory: studio/frontendcontinue-on-error: truerun: |set -o pipefail- LOG=logs-audit-signatures.txt- npm audit signatures 2>&1 | tee "$LOG"- {- echo "## npm audit signatures"- echo- echo '```'- tail -200 "$LOG"- echo '```'- } >> "$GITHUB_STEP_SUMMARY"-- - name: Extract base-ref lockfile (PR triggers only)- if: github.event_name == 'pull_request'- run: |- set -e- BASE_SHA="${{ github.event.pull_request.base.sha }}"- git show "$BASE_SHA:studio/frontend/package-lock.json" \- > /tmp/base-package-lock.json+ rc=0+ for dir in studio/frontend studio/backend/core/data_recipe/oxc-validator studio; do+ LOG="$dir/logs-audit-signatures.txt"+ (cd "$dir" && npm audit signatures) 2>&1 | tee "$LOG" || rc=1+ {+ echo "## npm audit signatures ($dir)"+ echo+ echo '```'+ tail -200 "$LOG"+ echo '```'+ } >> "$GITHUB_STEP_SUMMARY"+ done+ exit "$rc"- name: Diff for newly-added install-script depsif: github.event_name == 'pull_request'+ env:+ BASE_SHA: ${{ github.event.pull_request.base.sha }}run: |- python3 scripts/check_new_install_scripts.py \- --base /tmp/base-package-lock.json \- --head studio/frontend/package-lock.json+ set -e+ for lock in studio/frontend/package-lock.json studio/backend/core/data_recipe/oxc-validator/package-lock.json studio/package-lock.json; do+ # A lockfile the base does not have yet diffs against an empty tree.+ git show "$BASE_SHA:$lock" > /tmp/base-package-lock.json 2>/dev/null || echo '{}' > /tmp/base-package-lock.json+ python3 scripts/check_new_install_scripts.py --base /tmp/base-package-lock.json --head "$lock"+ done- name: Skip install-script diff (non-PR trigger)if: github.event_name != 'pull_request'@@ -1276,6 +1299,9 @@ jobs:if: always()with:name: npm-audit-signatures-log- path: studio/frontend/logs-audit-signatures.txt+ path: |+ studio/frontend/logs-audit-signatures.txt+ studio/backend/core/data_recipe/oxc-validator/logs-audit-signatures.txt+ studio/logs-audit-signatures.txtif-no-files-found: ignoreretention-days: 30diff --git a/.github/workflows/studio-tauri-smoke.yml b/.github/workflows/studio-tauri-smoke.ymlindex 866c4f092bf..3b8f340a0ac 100644--- a/.github/workflows/studio-tauri-smoke.yml+++ b/.github/workflows/studio-tauri-smoke.yml@@ -135,7 +135,7 @@ jobs:# defence against the npm postinstall-dropper class -- it fires# BEFORE any tarball runs, on the injection pattern itself# rather than an advisory-DB lookup.- run: npm install --save-dev --prefix studio @tauri-apps/[email protected] --no-fund --no-audit+ run: npm ci --prefix studio --no-fund --no-audit- name: Verify pinned Tauri CLI versionrun: |diff --git a/.github/workflows/wheel-smoke.yml b/.github/workflows/wheel-smoke.ymlindex b73efe2170a..e32588b3cab 100644--- a/.github/workflows/wheel-smoke.yml+++ b/.github/workflows/wheel-smoke.yml@@ -121,6 +121,8 @@ jobs:any(s.endswith(f"studio/frontend/dist/{f}") for s in n)for f in ("rounded-512.png", "unsloth.ico")),+ # setup.sh / setup.ps1 run `npm ci` against it in site-packages.+ "oxc lockfile shipped": any(s.endswith("oxc-validator/package-lock.json") for s in n),"no node_modules": not any("studio/frontend/node_modules/" in s for s in n),"no bun.lock": not any(s.endswith("studio/frontend/bun.lock") for s in n),}diff --git a/.github/workflows/workflow-trigger-lint.yml b/.github/workflows/workflow-trigger-lint.ymlindex 0d5c9bcf178..1d677be6032 100644--- a/.github/workflows/workflow-trigger-lint.yml+++ b/.github/workflows/workflow-trigger-lint.yml@@ -157,6 +157,7 @@ jobs:tests/studio/test_install_matrix_selection.py \tests/studio/test_install_phase_timing.py \tests/studio/test_installer_av_shapes.py \+ tests/studio/test_installers_npm_ci.py \tests/studio/test_mac_bundled_job_phases.py \tests/studio/test_mac_host_offload_optin.py \tests/studio/test_settings_smoke_covers_every_tab.py \diff --git a/build.sh b/build.shindex 58e7fb10f0a..ec953166d6d 100755--- a/build.sh+++ b/build.sh@@ -44,10 +44,10 @@ if [ -n "${UNSLOTH_NPM_REGISTRY:-}" ]; then_NPM_REGISTRY_ARGS=(--registry "$UNSLOTH_NPM_REGISTRY")fi-# Use bun for install if available (faster), fall back to npm.+# package-lock.json always wins (`npm ci`); bun only without one, since bun.lock is gitignored._install_ok=false-if command -v bun &>/dev/null; then- if bun install "${_NPM_REGISTRY_ARGS[@]+"${_NPM_REGISTRY_ARGS[@]}"}"; then+if [ ! -f package-lock.json ] && [ -f bun.lock ] && command -v bun &>/dev/null; then+ if bun install --frozen-lockfile "${_NPM_REGISTRY_ARGS[@]+"${_NPM_REGISTRY_ARGS[@]}"}"; then_install_ok=trueelseecho "⚠ bun install failed, falling back to npm"@@ -55,7 +55,9 @@ if command -v bun &>/dev/null; thenfifiif [ "$_install_ok" != "true" ]; then- if ! npm install "${_NPM_REGISTRY_ARGS[@]+"${_NPM_REGISTRY_ARGS[@]}"}"; then+ _npm_install=install+ [ -f package-lock.json ] && _npm_install=ci+ if ! npm "$_npm_install" "${_NPM_REGISTRY_ARGS[@]+"${_NPM_REGISTRY_ARGS[@]}"}"; thenecho "❌ ERROR: package install failed" >&2echo " If you are behind a corporate firewall/proxy, set UNSLOTH_NPM_REGISTRY to your mirror and retry, e.g.:" >&2echo " UNSLOTH_NPM_REGISTRY=https://your-mirror.example/api/npm/ ./build.sh" >&2diff --git a/studio/setup.ps1 b/studio/setup.ps1index 0a1516086a6..8ae20394588 100644--- a/studio/setup.ps1+++ b/studio/setup.ps1@@ -3090,7 +3090,8 @@ function Invoke-NpmMirrorRetry {$pairs = @(Pop-MirrorSpare npm)if (-not $pairs) { return $false }$registry = $pairs[0].Split('=', 2)[1]- if ((Invoke-SetupCommand { npm install --registry $registry }) -ne 0) { return $false }+ $verb = if (Test-Path "package-lock.json") { "ci" } else { "install" }+ if ((Invoke-SetupCommand { npm $verb --registry $registry }) -ne 0) { return $false }Set-MirrorEnv $pairs$script:NpmRegistryArgs = @('--registry', $registry)return $true@@ -5709,8 +5710,8 @@ if ($NeedNodeForSetup) {Remove-Item Env:NODE_PATH -ErrorAction SilentlyContinuestep "node" "$(node -v) | npm $(npm -v) (isolated)"- # bun (optional, faster installs); npm -g stays in the isolated prefix.- if (-not (Get-Command bun -ErrorAction SilentlyContinue)) {+ # bun (optional, unused when package-lock.json means `npm ci`); npm -g stays in the isolated prefix.+ if (-not (Test-Path (Join-Path $FrontendDir "package-lock.json")) -and -not (Get-Command bun -ErrorAction SilentlyContinue)) {substep "installing bun (faster frontend package installs)..."$prevEAP_bun = $ErrorActionPreference$ErrorActionPreference = "Continue"@@ -5757,12 +5758,14 @@ if ($NeedFrontendBuild -and -not $IsPipInstall) {$ErrorActionPreference = "Continue"Push-Location $FrontendDir- $UseBun = $null -ne (Get-Command bun -ErrorAction SilentlyContinue)+ # package-lock.json always wins (`npm ci`); bun only without one, since bun.lock is gitignored.+ $UseBun = -not (Test-Path "package-lock.json") -and (Test-Path "bun.lock") -and ($null -ne (Get-Command bun -ErrorAction SilentlyContinue))+ $NpmInstallVerb = if (Test-Path "package-lock.json") { "ci" } else { "install" }# A corrupt bun cache still exits 0, so validate, clear it, retry once, then fall back to npm.if ($UseBun) {Write-StudioLine " Using bun for package install (faster)" -ForegroundColor DarkGray- $bunExit = Invoke-SetupCommand { bun install @NpmRegistryArgs }+ $bunExit = Invoke-SetupCommand { bun install --frozen-lockfile @NpmRegistryArgs }# .bin/ entries vary by manager (npm: tsc/.cmd/.ps1; bun: .exe/.bunx).$hasTsc = (Test-Path "node_modules\.bin\tsc") -or (Test-Path "node_modules\.bin\tsc.cmd") -or (Test-Path "node_modules\.bin\tsc.exe") -or (Test-Path "node_modules\.bin\tsc.bunx")$hasVite = (Test-Path "node_modules\.bin\vite") -or (Test-Path "node_modules\.bin\vite.cmd") -or (Test-Path "node_modules\.bin\vite.exe") -or (Test-Path "node_modules\.bin\vite.bunx")@@ -5773,7 +5776,7 @@ if ($NeedFrontendBuild -and -not $IsPipInstall) {Remove-Item "node_modules" -Recurse -Force -ErrorAction SilentlyContinue}Invoke-SetupCommand { bun pm cache rm } | Out-Null- $bunExit = Invoke-SetupCommand { bun install @NpmRegistryArgs }+ $bunExit = Invoke-SetupCommand { bun install --frozen-lockfile @NpmRegistryArgs }$hasTsc = (Test-Path "node_modules\.bin\tsc") -or (Test-Path "node_modules\.bin\tsc.cmd") -or (Test-Path "node_modules\.bin\tsc.exe") -or (Test-Path "node_modules\.bin\tsc.bunx")$hasVite = (Test-Path "node_modules\.bin\vite") -or (Test-Path "node_modules\.bin\vite.cmd") -or (Test-Path "node_modules\.bin\vite.exe") -or (Test-Path "node_modules\.bin\vite.bunx")if ($bunExit -ne 0 -or -not $hasTsc -or -not $hasVite) {@@ -5792,14 +5795,14 @@ if ($NeedFrontendBuild -and -not $IsPipInstall) {}}if (-not $UseBun) {- $npmExit = Invoke-SetupCommand { npm install @NpmRegistryArgs }+ $npmExit = Invoke-SetupCommand { npm $NpmInstallVerb @NpmRegistryArgs }if ($npmExit -ne 0 -and (Invoke-NpmMirrorRetry)) { $npmExit = 0 }if ($npmExit -ne 0) {Pop-Location$ErrorActionPreference = $prevEAP_npmforeach ($gi in $HiddenGitignores) { Rename-Item -Path "$gi._twbuild" -NewName (Split-Path $gi -Leaf) -Force -ErrorAction SilentlyContinue }- Write-StudioLine "[ERROR] npm install failed (exit code $npmExit)" -ForegroundColor Red- Write-StudioLine " Try running 'npm install' manually in frontend/ to see errors" -ForegroundColor Yellow+ Write-StudioLine "[ERROR] npm $NpmInstallVerb failed (exit code $npmExit)" -ForegroundColor Red+ Write-StudioLine " Try running 'npm $NpmInstallVerb' manually in frontend/ to see errors" -ForegroundColor YellowShow-NpmRegistryHintExit-SetupFailure "Frontend dependency installation failed (exit code $npmExit)"}@@ -5836,12 +5839,13 @@ if ((Test-Path $OxcValidatorDir) -and $NodeSource -ne "skip" -and (Get-Command n$prevEAP_oxc = $ErrorActionPreference$ErrorActionPreference = "Continue"Push-Location $OxcValidatorDir- $oxcInstallExit = Invoke-SetupCommand { npm install @NpmRegistryArgs }+ $NpmInstallVerb = if (Test-Path "package-lock.json") { "ci" } else { "install" }+ $oxcInstallExit = Invoke-SetupCommand { npm $NpmInstallVerb @NpmRegistryArgs }if ($oxcInstallExit -ne 0 -and (Invoke-NpmMirrorRetry)) { $oxcInstallExit = 0 }if ($oxcInstallExit -ne 0) {Pop-Location$ErrorActionPreference = $prevEAP_oxc- Write-StudioLine "[ERROR] OXC validator npm install failed (exit code $oxcInstallExit)" -ForegroundColor Red+ Write-StudioLine "[ERROR] OXC validator npm $NpmInstallVerb failed (exit code $oxcInstallExit)" -ForegroundColor RedShow-NpmRegistryHintExit-SetupFailure "OXC validator dependency installation failed (exit code $oxcInstallExit)"}diff --git a/studio/setup.sh b/studio/setup.shindex bec88be2052..787e81229c1 100755--- a/studio/setup.sh+++ b/studio/setup.sh@@ -553,7 +553,7 @@ _CAPTURE_LOG=""_npm_mirror_retry() {[ "$(_mirror_failed_host "${_CAPTURE_LOG:-}" npm)" = npm ] && _mirror_take npm || return 1- run_quiet_no_exit "$1" npm install --no-fund --no-audit --loglevel=error --registry "${_MT_PAIRS#*=}" || return+ run_quiet_no_exit "$1" npm "${_NPM_INSTALL:-install}" --no-fund --no-audit --loglevel=error --registry "${_MT_PAIRS#*=}" || returnexport "$_MT_PAIRS"_NPM_REGISTRY_ARGS=(--registry "$UNSLOTH_NPM_REGISTRY")}@@ -2273,6 +2273,8 @@ else# isolated prefix); on a system Node we install nothing global. Build falls back to npm.if command -v bun &>/dev/null; thensubstep "bun already installed ($(bun --version))"+elif [ -f "$SCRIPT_DIR/frontend/package-lock.json" ]; then+ verbose_substep "skipping global bun install (package-lock.json installs with npm ci)"elif [ "$NODE_SOURCE" = bundled ]; thensubstep "installing bun..."# --allow-scripts=bun: npm >=11.16 gates install scripts and bun's@@ -2306,7 +2308,7 @@ _restore_gitignores() {}trap _restore_gitignores EXIT-# Use bun for install if available (faster), fall back to npm.+# package-lock.json always wins (`npm ci`); bun only without one, since bun.lock is gitignored.# Build always uses npm (Node runtime -- avoids bun runtime issues on some platforms).# NOTE: We intentionally avoid run_quiet for the bun install attempt because# run_quiet calls exit on failure, which would kill the script before the npm@@ -2320,7 +2322,7 @@ trap _restore_gitignores EXIT_try_bun_install() {local _log _exit_code=0_log=$(mktemp)- bun install "${_NPM_REGISTRY_ARGS[@]+"${_NPM_REGISTRY_ARGS[@]}"}" >"$_log" 2>&1 || _exit_code=$?+ bun install --frozen-lockfile "${_NPM_REGISTRY_ARGS[@]+"${_NPM_REGISTRY_ARGS[@]}"}" >"$_log" 2>&1 || _exit_code=$?# bun may create .exe shims on Windows (Git Bash / MSYS2) instead of plain scriptsif [ "$_exit_code" -eq 0 ] \@@ -2347,7 +2349,9 @@ _try_bun_install() {_FRONTEND_INSTALL_LOG=$(mktemp)_CAPTURE_LOG="$_FRONTEND_INSTALL_LOG"_bun_install_ok=false-if command -v bun &>/dev/null; then+_NPM_INSTALL=install+[ -f package-lock.json ] && _NPM_INSTALL=ci+if [ ! -f package-lock.json ] && [ -f bun.lock ] && command -v bun &>/dev/null; thensubstep "using bun for package install (faster)"if _try_bun_install; then_bun_install_ok=true@@ -2366,8 +2370,8 @@ if [ "$_bun_install_ok" = false ]; then# returns non-zero on failure) so the hint branch is reachable; it also captures# the exact exit code. Mirrors the `|| BUILD_OK=false` idiom used below._npm_install_rc=0- run_quiet_no_exit "npm install" npm install --no-fund --no-audit --loglevel=error "${_NPM_REGISTRY_ARGS[@]+"${_NPM_REGISTRY_ARGS[@]}"}" || _npm_install_rc=$?- if [ "$_npm_install_rc" -ne 0 ] && _npm_mirror_retry "npm install"; then+ run_quiet_no_exit "npm $_NPM_INSTALL" npm "$_NPM_INSTALL" --no-fund --no-audit --loglevel=error "${_NPM_REGISTRY_ARGS[@]+"${_NPM_REGISTRY_ARGS[@]}"}" || _npm_install_rc=$?+ if [ "$_npm_install_rc" -ne 0 ] && _npm_mirror_retry "npm $_NPM_INSTALL"; then_npm_install_rc=0fiif [ "$_npm_install_rc" -ne 0 ]; then@@ -2408,8 +2412,10 @@ if [ -d "$_OXC_DIR" ] && [ "${NODE_SOURCE:-}" != skip ] && command -v npm &>/dev# `|| _oxc_install_rc=$?` keeps this off `set -e`'s exit path so the hint branch# below is reachable; it also captures the exact exit code._oxc_install_rc=0- run_quiet_no_exit "npm install (oxc validator runtime)" npm install --no-fund --no-audit --loglevel=error "${_NPM_REGISTRY_ARGS[@]+"${_NPM_REGISTRY_ARGS[@]}"}" || _oxc_install_rc=$?- if [ "$_oxc_install_rc" -ne 0 ] && _npm_mirror_retry "npm install (oxc validator runtime)"; then+ _NPM_INSTALL=install+ [ -f package-lock.json ] && _NPM_INSTALL=ci+ run_quiet_no_exit "npm $_NPM_INSTALL (oxc validator runtime)" npm "$_NPM_INSTALL" --no-fund --no-audit --loglevel=error "${_NPM_REGISTRY_ARGS[@]+"${_NPM_REGISTRY_ARGS[@]}"}" || _oxc_install_rc=$?+ if [ "$_oxc_install_rc" -ne 0 ] && _npm_mirror_retry "npm $_NPM_INSTALL (oxc validator runtime)"; then_oxc_install_rc=0fi_CAPTURE_LOG=""diff --git a/tests/sh/test_mirror_fallback.sh b/tests/sh/test_mirror_fallback.shindex df73e6b4c92..1389d9e3574 100644--- a/tests/sh/test_mirror_fallback.sh+++ b/tests/sh/test_mirror_fallback.sh@@ -320,6 +320,7 @@ _npm_mirror_retry 'npm install'; echo \"RC \$? REG=\${UNSLOTH_NPM_REGISTRY:-} ARNPMM=https://registry.npmmirror.comassert_eq "npm: a registry transport failure reruns once on npmmirror, which later installs keep" "STEP registry.npmjs.org failed; retrying through $NPMM|RUN npm install --no-fund --no-audit --loglevel=error --registry $NPMM|RC 0 REG=$NPMM ARGS=--registry $NPMM" "$(_npm "$_fail_npm")"assert_eq "npm: ... not when the rerun fails too" "STEP registry.npmjs.org failed; retrying through $NPMM|RUN npm install --no-fund --no-audit --loglevel=error --registry $NPMM|RC 1 REG= ARGS=" "$(_npm "$_fail_npm" MIRROR_FAILS=1)"+assert_eq "npm: the rerun keeps npm ci when the directory has a lockfile" "STEP registry.npmjs.org failed; retrying through $NPMM|RUN npm ci --no-fund --no-audit --loglevel=error --registry $NPMM|RC 0 REG=$NPMM ARGS=--registry $NPMM" "$(_npm "$_fail_npm" _NPM_INSTALL=ci)"assert_eq "npm: a dependency conflict is not retried" "RC 1 REG= ARGS=" "$(_npm 'npm error code ERESOLVE: While resolving: [email protected] from https://registry.npmjs.org/vite')"summarydiff --git a/tests/studio/test_installers_npm_ci.py b/tests/studio/test_installers_npm_ci.pynew file mode 100644index 00000000000..9e799611c1d--- /dev/null+++ b/tests/studio/test_installers_npm_ci.py@@ -0,0 +1,90 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved.+"""Studio installs of a committed package-lock.json go through `npm ci`, never `npm install`.++`npm install` rewrites the lockfile when package.json drifts from it and installs whatever+the drift asks for, so the audited lockfile stops being what gets installed.+"""++import re+from pathlib import Path++import yaml++REPO = Path(__file__).resolve().parents[2]+LOCKED_DIRS = ("studio", "studio/frontend", "studio/backend/core/data_recipe/oxc-validator")+# `npm install` survives only as the no-lockfile fallback verb and the global bun install.+_BARE_INSTALL = re.compile(r"\bnpm\s+install\b(?!\s+-g\b)")+++def _read(rel):+ return (REPO / rel).read_text(encoding = "utf-8")+++def test_lockfiles_are_committed():+ for d in LOCKED_DIRS:+ assert (REPO / d / "package-lock.json").is_file(), d+++def test_installers_pick_npm_ci_when_a_lockfile_exists():+ sh = _read("studio/setup.sh")+ assert sh.count("[ -f package-lock.json ] && _NPM_INSTALL=ci") == 2+ assert 'npm "${_NPM_INSTALL:-install}"' in sh+ build = _read("build.sh")+ assert "[ -f package-lock.json ] && _npm_install=ci" in build+ ps1 = _read("studio/setup.ps1")+ assert ps1.count('if (Test-Path "package-lock.json") { "ci" } else { "install" }') == 3+ for rel, text in (("studio/setup.sh", sh), ("build.sh", build), ("studio/setup.ps1", ps1)):+ code = "\n".join(l for l in text.splitlines() if not l.lstrip().startswith("#"))+ bare = [+ l.strip()+ for l in code.splitlines()+ if _BARE_INSTALL.search(l) and "Write-StudioLine" not in l+ ]+ assert bare == [], f"{rel}: {bare}"+++def test_bun_only_runs_against_a_committed_bun_lock():+ gate = "if [ ! -f package-lock.json ] && [ -f bun.lock ] && command -v bun &>/dev/null; then"+ assert gate in _read("studio/setup.sh")+ assert gate in _read("build.sh")+ assert (+ '$UseBun = -not (Test-Path "package-lock.json") -and (Test-Path "bun.lock") -and'+ in _read("studio/setup.ps1")+ )+ for rel in ("studio/setup.sh", "build.sh"):+ assert 'bun install "${_NPM_REGISTRY_ARGS' not in _read(rel), rel+ assert 'bun install --frozen-lockfile "${_NPM_REGISTRY_ARGS' in _read(rel), rel+ assert "{ bun install @NpmRegistryArgs }" not in _read("studio/setup.ps1")+++def test_bun_is_not_provisioned_when_npm_ci_will_run():+ sh = _read("studio/setup.sh")+ skip = sh.index('elif [ -f "$SCRIPT_DIR/frontend/package-lock.json" ]; then')+ assert (+ skip+ < sh.index('elif [ "$NODE_SOURCE" = bundled ]; then', skip)+ < sh.index("npm install -g bun", skip)+ )+ ps1 = _read("studio/setup.ps1")+ gate = 'if (-not (Test-Path (Join-Path $FrontendDir "package-lock.json")) -and -not (Get-Command bun'+ assert ps1.index(gate) < ps1.index("npm install -g bun")+++def test_workflows_install_lockfiled_dirs_with_npm_ci():+ for name in (+ "release-desktop.yml",+ "studio-tauri-smoke.yml",+ "desktop-app-clean-machine-ci.yml",+ ):+ doc = yaml.safe_load(_read(f".github/workflows/{name}"))+ for job_id, job in doc["jobs"].items():+ for step in job.get("steps") or []:+ run = step.get("run") if isinstance(step, dict) else None+ if isinstance(run, str):+ bare = [+ l.strip()+ for l in run.splitlines()+ if _BARE_INSTALL.search(l) and not l.lstrip().startswith("#")+ ]+ assert bare == [], f"{name}:{job_id}: {bare}"