From c845e726929da51988485e7f470804677b68ed6d Mon Sep 17 00:00:00 2001 From: danielhanchen Date: Fri, 24 Jul 2026 11:09:12 +0000 Subject: [PATCH] Harden torch-constraint test grep portability and clear kept-torch on failure - test_torch_constraint.sh: use grep -E for the hardcoded-range guard. The BRE \| alternation is a GNU extension; on BSD/macOS grep it can be a literal, so the regression guard could silently no-op on a supported platform. - install.ps1: clear UNSLOTH_KEPT_TORCH in Exit-InstallFailure. A non-Tauri irm | iex run throws while the caller session stays alive, so a leaked kept-torch handoff could let a later setup/update re-pin an abandoned exact torch release. --- install.ps1 | 5 +++++ tests/sh/test_torch_constraint.sh | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/install.ps1 b/install.ps1 index 3d709ae1ff..f64021c629 100644 --- a/install.ps1 +++ b/install.ps1 @@ -87,6 +87,11 @@ function Install-UnslothStudio { ) if ($Code -eq 0) { $Code = 1 } Write-TauriLog "ERROR" $Message + # Clear the release-preservation handoff on any failure: a non-Tauri `irm | iex` + # run throws below and leaves the caller's session alive, so a leaked + # UNSLOTH_KEPT_TORCH would let a later `studio setup`/`update` (or a retry that + # skips the branch-entry clear) re-pin the abandoned exact torch release. + Remove-Item Env:UNSLOTH_KEPT_TORCH -ErrorAction SilentlyContinue if (Get-Command Restore-StudioVenvRollback -CommandType Function -ErrorAction SilentlyContinue) { Restore-StudioVenvRollback } diff --git a/tests/sh/test_torch_constraint.sh b/tests/sh/test_torch_constraint.sh index d36581987b..24e12787e2 100644 --- a/tests/sh/test_torch_constraint.sh +++ b/tests/sh/test_torch_constraint.sh @@ -115,7 +115,7 @@ assert_eq "\$TORCH_CONSTRAINT used in pip install" "yes" "$_has_var" # No stray hardcoded default ranges outside the ceiling-composed assignments # (the curated ROCm >=2.11 floors are deliberately literal). -_hardcoded=$(grep -c '"torch>=2.4,<2.11.0"\|"torch>=2.4,<2.12.0"' "$INSTALL_SH" || true) +_hardcoded=$(grep -E -c '"torch>=2.4,<2.11.0"|"torch>=2.4,<2.12.0"' "$INSTALL_SH" || true) assert_eq "no hardcoded default torch range remains" "0" "$_hardcoded" # Companions must be bounded to torch's window everywhere, never bare: torchaudio