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.
This commit is contained in:
danielhanchen 2026-07-24 11:09:12 +00:00
commit c845e72692
2 changed files with 6 additions and 1 deletions

View file

@ -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
}

View file

@ -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