Repository navigation
Studio: record how a Windows install was launched and what it produced - #8066
Conversation
|
Note on the red checks. None of them are from this PR, which touches only
That is a separate pre-existing bug on
|
|
Worked through all four review points. Three were right and are fixed in 5eb3f46; the fourth is real but I have not taken the suggested remedy. Details below. Gate the elevation marker on the parsed Tauri flag. Correct, and it was the important one. Verified in Name the active custom install root. Correct. Record degraded llama.cpp during desktop updates. Correct. Warn before the desktop process creates the install root. The premise is right, the remedy is not one I can justify. Verification:
|
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
The follow-up point about the custom install root is correct too, and unlike the desktop one it is fixable entirely inside Verified the ordering: the resolver calls The notice now runs immediately after flag parsing. Mutation-checked again: moving the call back below the resolver fails 2 of the 14 tests. Still not touching the |
81c0944 to
7e17d5f
Compare
|
Rebased onto current No code change in this push beyond the rebase; the four review fixes are unchanged and still green locally (14 Python tests, 17 shell assertions). |
|
On the red
Cause: e99651b (#8074) fixed the duplicate The runtime fix is right. But Happy to send that one-line change as a separate PR if it is wanted here rather than left to whoever owns #8074. |
|
Breakdown of the current reds, neither from this branch.
|
Two things a support report could not answer about a failed Windows install. Elevation. An install started with "Run as administrator" writes %USERPROFILE%\.unsloth as Administrators, the normal account cannot read it back, and the folder outlives an uninstall, so the next install fails on a folder nobody remembers creating. Nothing recorded whether a run was elevated, and nothing warned while the user could still close the window. install.ps1 and setup.ps1 now read the process token, warn when it will create admin-owned files, and emit the state as [TAURI:DIAG] elevated=... on every run, since "false" is what rules elevation out. llama.cpp availability. In Tauri mode a degraded llama.cpp is deliberately not fatal, but it was announced only through install-progress-detail, which the next install-step clears and the install screen discards on close. The install then looked clean and the first sign of trouble was a GGUF failing to load. setup.ps1 and setup.sh now also emit [TAURI:DIAG] llama_cpp=unavailable beside the existing notice. Both use the [TAURI:DIAG] channel install.rs already parses, so the markers land in the support report under installer_diag_markers with no Rust change. The non-desktop contract is unchanged: setup still exits non-zero there.
… repairs install.rs launches install.ps1 with --tauri and never sets UNSLOTH_TAURI_MODE; install.ps1 assigns that variable itself much later, right before invoking setup.ps1. Gating the marker on the env var emitted nothing for the desktop install, and setup.ps1 then skipped its own marker under SKIP_STUDIO_BASE=1, so the flow this exists for recorded no elevated= line at all. Gate on the parsed flag instead. A custom UNSLOTH_STUDIO_HOME holds every artefact, so a hardcoded %USERPROFILE%\.unsloth named the wrong directory. install.ps1 uses the resolved root; setup.ps1 resolves $StudioHome much later, so it mirrors the override precedence for the message only. update.rs sets UNSLOTH_TAURI_UPDATE alone, neither SKIP_STUDIO_BASE nor UNSLOTH_TAURI_MODE, so a degraded desktop repair recorded nothing. It parses [TAURI:DIAG] the same way, so add a marker-only block for it. The update exit contract is unchanged. The warning no longer says to close a window and re-run from PowerShell: install.rs spawns the script from the desktop app, where there is neither.
The override resolver calls CreateDirectory on a custom UNSLOTH_STUDIO_HOME and writes a probe into it, both before the notice ran. An elevated run that followed the advice to stop had therefore already created the admin-owned folder the warning is about. Move the notice ahead of the resolver. $StudioHome does not exist that early, so the root shown is derived from the override precedence directly, the same way setup.ps1 already does it, and a test pins the two resolutions together. The notice now prints before the banner, which is the cost of warning while stopping still leaves nothing behind.
7e17d5f to
1aaa576
Compare
An override that resolves to %USERPROFILE%\.unsloth\studio is not a custom root downstream: the canonical comparison treats it as a default install and keeps llama.cpp and node as siblings under ~/.unsloth. The warning named only the studio directory, so following it left the admin-owned assets behind. Both scripts now map a legacy-equal override to that parent. install.ps1 set SKIP_STUDIO_BASE=1 for the child setup and never restored it. 'irm ... | iex' runs in the caller's shell, so the next direct setup or update in that session inherited the flag, and setup.ps1's guard then took the run for an installer child and suppressed the elevation notice, the elevated= marker and the degraded-repair marker. Save and restore it alongside UNSLOTH_TAURI_MODE, which the same block already does.
…he finally The legacy-root comparison was a raw string compare with a TrimEnd. The env override reaches it unresolved, so the spellings a user actually types miss: '~/.unsloth/studio', forward slashes, and a '..' segment all name the legacy root but compared unequal, and the notice then named the studio directory and sent the user past the admin-owned llama.cpp beside it. Both scripts now expand a leading ~ and run GetFullPath before comparing, matching the canonical resolver already used for the hipInfo filter. Separately, --with-llama-cpp-dir with a missing path returns before '& $UnslothExe', and that return sat between the env mutations and the try, so the bail still leaked SKIP_STUDIO_BASE, UNSLOTH_STUDIO_HOME and UNSLOTH_TAURI_MODE into the caller's shell. The saves stay outside the try because they read the previous value; the try now opens before the first mutation.
|
Both remaining points addressed in 89b1518. The legacy-root comparison was not canonical. It was a raw string compare with a Both scripts now expand a leading I checked the resolution table against a faithful port of the helper: exact, trailing separator, forward slashes,
Two tests, both mutation-checked. Reverting the One caveat worth stating plainly: |
install.ps1 conflicted: main took the same save-and-restore approach for its own handoff variables while this branch was open. Kept every one of main's env vars and restores, and re-applied this branch's two changes on top -- SKIP_STUDIO_BASE is saved and restored too, and the try opens before the first mutation so the --with-llama-cpp-dir bail restores as well. Every capture now sits above the try, so a finally reached early cannot read an unset flag as "there was nothing here". Two things the merge broke rather than conflicted on. main moved setup.ps1's override resolver ahead of where this branch printed the elevation warning, and that resolver creates and write-probes the custom root -- the exact folder the warning tells you not to create. The block moves back above it. And the warnings still called Write-Host, which main routed through the UTF-8 sink in #8148: under CREATE_NO_WINDOW the desktop app renders those as U+FFFD, which is the flow this branch exists for.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex security review |
Codex review item on install.ps1:6632, and it is correct.
The finally ended with three bare Remove-Items for UNSLOTH_LOCAL_LLAMA_CPP_DIR,
UNSLOTH_INSTALL_ROLLBACK_MANAGED and UNSLOTH_SETUP_PYTHON. That was survivable only while
the finally could not be reached without having set them. This branch moved the try above
the first mutation so the --with-llama-cpp-dir bail restores, and the same move means that
bail now reaches the finally having assigned none of the three, and clears whatever the
caller had.
UNSLOTH_LOCAL_LLAMA_CPP_DIR is not an internal handoff. install.ps1 reads it itself as a
user-facing input, so a caller having it set is the ordinary case rather than a contrived
one, and a mistyped --with-llama-cpp-dir silently destroyed it in the caller's session
under `irm | iex`. A successful install cleared it too, which predates this branch.
Measured in-process under pwsh over the same matrix as the rest of the table, every
variable x {unset, empty, populated} x {succeeds, bail, throws}: 18 failures before, 136
of 136 after. The unset case still ends unset rather than empty.
The regression test now covers all fifteen managed variables, and was mutation-checked:
turning any one restore back into a bare Remove-Item fails it.
Parity 659 passed 8 skipped, elevation report 19 passed, shell suite 17 passed,
install.ps1 parses with 0 errors.
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Post-convergence comment pass. Comments only, no behaviour change. The comment lines this branch adds go from 140 to 62, 55 percent fewer. Two sweeps: the first shortened, the second deleted. Section banners went, as did headers that restated the function immediately under them (Get-CanonicalRootPath had three lines saying it canonicalizes a root path). Multi-line rationales collapse to one or two lines that keep the fact and drop the retelling: the fourteen lines on GetUnresolvedProviderPathFromPSPath are now three, keeping what a reader cannot recover from the code, that GetFullPath uses a working directory Set-Location does not move, and the citation. Two comments are deliberately left long. Get-ElevationState still says why elevation is worth recording at all, and the handoff save block still explains why the captures sit above the try, because that is the bug class the ordering exists to prevent. Excluded from the count: 35 comment lines that show as added only because the try/finally restructure re-indented pre-existing text from main. Rewriting those would enlarge the diff a reviewer has to read for no gain. studio/setup.sh is left alone. Its three comment lines could be cut the same way, but comment_tools.py's shell lexer reports the result as CODE CHANGED: unlike the PowerShell lexer it does not strip these comments from the code-only signature, so the gate cannot pass any comment edit in that file. It fails closed by design, so the edit is reverted rather than pushed past it. The change was independently comment-only (non-comment lines byte-identical, every changed line a comment), which is why this is a tooling limit and not a finding. Gate is 4 of 4 code unchanged. 105 pytest passed 17 skipped, shell suite 17 passed, ruff clean, and the four simulation harnesses are 214 of 214.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…t cannot tests/test_windows_amd_gpu_scan_fallback.py lifts install.ps1's save/set/try/finally block out of the shipped script by string markers and runs it under pwsh. #8066 grew that block from 61 lines to 197 and added calls to Get-ExpectedTorchFlavorTag, Get-InstalledTorchVersionRaw, Write-StudioLine, Write-ApplicationControlBlocked and Exit-InstallFailure, plus reads of $VenvDir and $script:ManagedUnslothCliExit. None of those exist in the synthesized script, so the block threw on its first helper call. The production change is correct: the handoff is still set, cleared and restored, and the --with-llama-cpp-dir bail moved INSIDE the try, so the finally now covers a path that previously sat outside it. Only the test was wrong. Two failure modes, and the second was the worse one: - Four tests failed with "assert '<never ran>' == 'gfx1151'", which names neither the missing helper nor the fact that the block never ran, because the catch swallowed the error. It is recorded as block_error now and asserted directly, so the next helper added to install.ps1 says "The term 'X' is not recognized" instead. Verified by deleting a stub: the failure names it. - Eight more tests were PASSING while the block threw, asserting over an environment it never touched. Surfacing block_error turned those into honest failures, which is why this fixes 4 visible failures by first exposing 12. test_installer_restores_the_private_handoff_after_setup asserted "the save sits after the last early return", a proxy for "no path skips the restore" that only held for the old shape and that #8066 inverted. It now asserts the structure the guarantee needs: save, then try, with the early return between the try and the finally that restores. 82 passed.
…t cannot tests/test_windows_amd_gpu_scan_fallback.py lifts install.ps1's save/set/try/finally block out of the shipped script by string markers and runs it under pwsh. #8066 grew that block from 61 lines to 197 and added calls to Get-ExpectedTorchFlavorTag, Get-InstalledTorchVersionRaw, Write-StudioLine, Write-ApplicationControlBlocked and Exit-InstallFailure, plus reads of $VenvDir and $script:ManagedUnslothCliExit. None of those exist in the synthesized script, so the block threw on its first helper call. The production change is correct: the handoff is still set, cleared and restored, and the --with-llama-cpp-dir bail moved INSIDE the try, so the finally now covers a path that previously sat outside it. Only the test was wrong. Two failure modes, and the second was the worse one: - Four tests failed with "assert '<never ran>' == 'gfx1151'", which names neither the missing helper nor the fact that the block never ran, because the catch swallowed the error. It is recorded as block_error now and asserted directly, so the next helper added to install.ps1 says "The term 'X' is not recognized" instead. Verified by deleting a stub: the failure names it. - Eight more tests were PASSING while the block threw, asserting over an environment it never touched. Surfacing block_error turned those into honest failures, which is why this fixes 4 visible failures by first exposing 12. test_installer_restores_the_private_handoff_after_setup asserted "the save sits after the last early return", a proxy for "no path skips the restore" that only held for the old shape and that #8066 inverted. It now asserts the structure the guarantee needs: save, then try, with the early return between the try and the finally that restores. 82 passed.
… it drives (#10538) * Catch the handoff harness up with the block it drives, and make it say why when it cannot main fails four cases in tests/test_windows_amd_gpu_scan_fallback.py. The lifecycle harness lifts install.ps1's save / set / try / finally block and runs it with the setup call replaced by a probe. That block has since grown a dependency on the installer's own inputs and helpers (Get-ExpectedTorchFlavorTag and the torch pin check from #10524, Write-ApplicationControlBlocked from #8066), and it reads $script:ManagedUnslothCliExit on the line right after the call it replaces, then returns early when that exit code is null. None of those were bound, so under ErrorActionPreference Stop the block threw, the harness's own catch swallowed it, and every assertion read "never ran" -- which looks like a handoff defect and is not one. Bound them, and made the harness loud rather than silent: the replacement is asserted to have matched, the swallowed error is reported back and fails the test with its message, and the report is read as the last JSON line so a stub's own output cannot be mistaken for it. The fourth failure was an ordering assertion, that the save appears after the --with-llama-cpp-dir bail in file order. That bail now sits inside the try whose finally restores, which is a stronger arrangement than the ordering stood for, so the check is now the arrangement itself: save, then the bail, then the restore. Still a real test: dropping the inherited-handoff clear from install.ps1 fails stale_only, and restoring it passes. 82 tests in the file. * Run the bail rather than reading its offsets, and require the injected throw Two review points, both about this harness accepting less than it claims. The setup_throws cases skipped the error assertion entirely, so any exception passed: a helper failing before the setup call would leave the shipped finally to restore the environment, and every assertion would hold without the failure path ever running. They now require the injected "setup exploded" and fail on anything else. Checked by calling an undefined function before the setup call: all four cases fail, and pass again once it is removed. The restore invariant was three string offsets, which establish order and not structure. The block now runs inside a function, so its own return leaves the block rather than the script, and a new case takes the --with-llama-cpp-dir bail with a directory that does not exist and reads the environment afterwards. It asserts on the two variables the block sets at the top of its try, above the bail, since those are what say the finally ran rather than that nothing happened. Checked by moving the assignments and the bail out of the try, which the textual ordering still accepts and this rejects. 83 tests in the file. * Tighten the comments in the handoff lifecycle harness Collapse the multi-line explanations added with the bail test down to one or two lines each, and drop the parts the code already says. No behaviour change: comments and whitespace only. --------- Co-authored-by: danielhanchen <[email protected]>
Summary
Two things a support report could not answer about a failed Windows install, both from the same report.
Was the run elevated? An install started with "Run as administrator" writes
%USERPROFILE%\.unslothowned by Administrators. The same account cannot read it back from a normal shell, and the folder outlives an uninstall, so a later install, setup or update fails on a folder nobody remembers creating. Nothing recorded whether a run was elevated, and nothing warned while the user could still close the window and start over.Did llama.cpp actually land? In Tauri mode a degraded llama.cpp is deliberately not fatal, so one transient prebuilt download failure does not throw away a first-launch install. But it was announced only through
install-progress-detail, which the nextinstall-stepclears and the install screen discards on close. The install then looked clean, and the first sign of trouble was a GGUF failing to load with "the llama.cpp runtime is not installed".What changed
install.ps1andstudio/setup.ps1read the process token and report the result astrue,false, orunknownwhen the token cannot be read.%USERPROFILE%\.unsloth, says it outlives an uninstall, and says to re-run from a normal PowerShell. It is a warning, not a block, since elevation is not always a mistake.install.rscreates~/.unslothitself before spawning the script, so stopping is not entirely free on the desktop; the wording does not claim otherwise.[TAURI:DIAG] elevated=...on every run, not only the bad one.falseis the answer that rules elevation out; absence would be ambiguous.--tauriflag, notUNSLOTH_TAURI_MODE.install.rsnever sets that variable;install.ps1assigns it itself, far below, right before invokingsetup.ps1.UNSLOTH_STUDIO_HOMEis not sent to the wrong directory.setup.ps1skips this whenSKIP_STUDIO_BASE=1, becauseinstall.ps1has already reported it for the install it drives. That leaves directunsloth studio setup,unsloth studio update, and desktop repair covered without duplicating the marker.studio/setup.ps1andstudio/setup.shemit[TAURI:DIAG] llama_cpp=unavailablealongside the existing progress notice when the run ends without a usable server.A second, marker-only block covers desktop repair.
update.rssetsUNSLOTH_TAURI_UPDATEalone, neitherSKIP_STUDIO_BASEnorUNSLOTH_TAURI_MODE, so the install-side block never ran on a repair. It parses[TAURI:DIAG]the same way, and the update exit contract is unchanged.Both use the
[TAURI:DIAG]channelinstall.rsalready parses, so the markers reachrecord_diag_markerand print in the support report underinstaller_diag_markers. No Rust or frontend change.Behavior boundaries
install.shandinstall.ps1still fail.tests/sh/test_llama_degraded_tauri_mode.shpins both halves and still passes.[TAURI:PROGRESS]notice is unchanged; the marker is added beside it, not in place of it.UNSLOTH_TAURI_UPDATErather thanUNSLOTH_TAURI_MODE, so the elevation marker checks both.unknownrather than failing the run or claimingfalse.What this does not do
This makes a degraded install visible in the support report and in the log stream. It does not yet put a proactive notice in the app itself, so a desktop user whose prebuilt download failed still finds out at model-load time. That needs a completed-with-warnings state in
install.rsand a surface in the frontend, which is worth doing separately rather than folding into a scripts-only change.Testing
tests/test_installer_elevation_report.py(8 tests) pins:[TAURI:DIAG]channel is still parsed byinstall.rsand still printed byreport.rs, so the markers cannot go silently unreadtrue,falseandunknownare all reachablesetup.ps1covers repair viaUNSLOTH_TAURI_UPDATEand skips the duplicate underSKIP_STUDIO_BASE=1tests/sh/test_llama_degraded_tauri_mode.shgains two assertions: Tauri mode emits the marker, andsetup.ps1mirrors it.Also run:
python -m pytest tests/test_installer_elevation_report.py -q(8 passed)bash tests/sh/test_llama_degraded_tauri_mode.sh(10 passed)tests/sh/*.shsuite (4 pre-existing macOS-host failures, identical onmain)python -m pytest tests/studio tests/python/test_cross_platform_parity.py tests/test_installer_system32_guard.py -q(2521 passed, up 8 frommain; the 113 failures are cases needing a working local pwsh and are identical onmain)bash -n studio/setup.sh