Skip to content

Add option to launch Studio without opening the default browser - #7016

Merged
danielhanchen merged 10 commits into
mainfrom
launcher-no-browser
Aug 6, 2026
Merged

danielhanchen merged 10 commits into
mainfrom
launcher-no-browser

Conversation

@shimmyshimmer

Copy link
Copy Markdown
Member

Summary

The desktop launchers generated by the installers (launch-studio.sh on macOS/Linux/WSL, launch-studio.ps1 on Windows) always open the default browser once the server passes its health check, with no way to opt out. Users who run Studio as a browser PWA or app window (for example a Vivaldi app window while Firefox is the OS default browser) want the server up without the default browser popping open every launch.

Note that unsloth studio from a terminal is unchanged and has never auto-opened a browser; this only touches the desktop launcher path.

Changes

  • Both launchers accept --no-browser (PowerShell also -NoBrowser) and honor UNSLOTH_STUDIO_NO_BROWSER=1. When auto-open is off the launcher still starts or attaches to the server and prints Unsloth Studio is running at: <url> instead of opening it
  • Interactive installs now ask once: Open Unsloth Studio in your default browser after launch? [Y/n]. Enter keeps the current behavior (yes). The answer is persisted: STUDIO_OPEN_BROWSER in studio.conf on macOS/Linux/WSL, baked into launch-studio.ps1 on Windows
  • ./install.sh --no-browser and install.ps1 --no-browser set the preference non-interactively; --browser sets it back. Combined with --shortcuts-only this flips an existing install without reinstalling
  • The --shortcuts-only refresh run by unsloth studio update preserves the stored choice instead of resetting it
  • All three Start-Process "http://..." sites in the Windows launcher now route through a gated Open-StudioUrl helper
  • README Launch section documents the behavior

Testing

  • New tests/sh/test_launcher_no_browser.sh (18 assertions): static shape checks on both installers plus a functional check that drives the extracted _open_browser with stubbed open/xdg-open binaries. All pass; sh -n and bash -n are clean
  • Fresh local install on macOS: studio.conf gets STUDIO_OPEN_BROWSER='1' by default. Against a healthy server, launch-studio.sh --no-browser and UNSLOTH_STUDIO_NO_BROWSER=1 print the URL and open nothing; the default path opens the browser exactly once (verified with a stubbed open on PATH recording invocations)
  • ./install.sh --shortcuts-only --no-browser flips the stored preference to '0' and a subsequent plain --shortcuts-only refresh (the studio update scenario) keeps it
  • The three pre-existing failures in tests/sh/test_install_host_defaults.sh also fail on a clean checkout of main and are unrelated

The generated launchers (launch-studio.sh / launch-studio.ps1) always
opened the default browser once the server became healthy. Add a
--no-browser launcher flag, the UNSLOTH_STUDIO_NO_BROWSER env var, and
a persisted installer preference (studio.conf / baked into the ps1
launcher) with an interactive install prompt. When auto-open is off the
launcher still starts or attaches to the server and prints the URL, for
users who run Studio as a browser PWA or app window. The
--shortcuts-only refresh run by studio update preserves the choice.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: c980658592

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

…ell launcher

Simulation testing caught that False or Off disabled the browser in
launch-studio.sh while the PowerShell launcher's -notin treats them as
falsy case-insensitively. Lowercase the value before matching so both
launchers agree, and pin the behavior in the launcher test.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

Ran a full simulation pass on this before merge to make sure the default path cannot regress on any platform.

Method: every test runs the real launcher generated from the installer templates (the bash launcher via the same sed substitution install.sh performs, the Windows launcher by expanding install.ps1's actual here-string), against a mock backend that serves /api/health with a configurable studio_root_id, inside throwaway sandboxes (own HOME, XDG_RUNTIME_DIR, data dir, uv venv for the mock server). The OS browser-opening layer is stubbed on PATH (open, xdg-open, powershell.exe, cmd.exe) so runs record exactly what would have been opened. Linux and WSL branches are exercised through uname and /proc/version probes; the Windows launcher runs for real under PowerShell 7 with Start-Process shadowed. Since all launchers hand the URL to the OS default-browser mechanism, a per-browser dispatch simulation (Firefox, Safari, Chrome, Edge) verifies each receives the identical unmangled URL.

Coverage, 139 checks total, three consecutive full runs green:

  • bash launcher matrix (71): preference precedence (conf vs env var vs flags, last flag wins), legacy pre-PR studio.conf, garbage conf values, fast path, cold start with and without TTY, lock contention (two launchers, one server), root-id mismatch and dead/unhealthy port refusal, timeout prints no false URL, default-mode port scanning that skips foreign Studios, and per-OS opener fallback chains including the no-opener case
  • installer matrix (19): fresh default writes '1', --no-browser and --browser flips, plain --shortcuts-only refresh preserves the choice (the studio update path), legacy conf migration, garbage value normalization, a conf injection attempt is not preserved verbatim and executes nothing, the interactive prompt driven through a real pty (n, y, Enter, NO, unrecognized input), and non-interactive runs never prompt
  • PowerShell matrix (30): install.ps1 and the generated launch-studio.ps1 both parse with zero AST errors, then the generated launcher executes the same precedence, env var, mismatch, and dead-port cases

One real bug found and fixed in 52acbcc: UNSLOTH_STUDIO_NO_BROWSER=False or Off disabled the browser in the shell launcher because the falsy check was case-sensitive, while the PowerShell launcher's -notin is case-insensitive. The value is now lowercased before matching and the launcher test pins it.

Everything else passed unchanged, including the guarantee that a default install with no flags, no env var, and Enter at the prompt opens the browser exactly once, same as before this PR.

The shell installer test step runs a hardcoded list, so the new
tests/sh/test_launcher_no_browser.sh was only bash -n parsed by lint
and never executed. Add it to the list; it only reads install.sh and
install.ps1 and writes to mktemp sandboxes, so it fits the step's
no-writable-tree constraint.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

An interactive reinstall over an install that had persisted
STUDIO_OPEN_BROWSER='0' would flip it back to 1 when the user pressed
Enter, because the prompt default was hardcoded to yes and the answer
then overrode the preserve logic. Seed the prompt default from the
existing preference (studio.conf on macOS/Linux/WSL, the value baked in
launch-studio.ps1 on Windows) and flip the hint to [y/N] accordingly.
Explicit y/n answers still override.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

grep -q exiting on first match SIGPIPEs the echo feeding it when the
haystack is the whole installer, spamming 'write error: Broken pipe'
in the CI job log. Feed grep from here-strings instead.
@ehlesp

ehlesp commented Jul 9, 2026

Copy link
Copy Markdown

Mike asked me to test this new "no-browser" feature in the forum thread where I suggested it, so here is my summary report about my tests in different setups:

Testing Environments

  • Kubuntu 24.04, with KDE Plasma 5.27 as desktop.

  • Linux Mint 22.3 "Zena", with Cinnamon 6.6 as desktop.

  • Windows 11.

Commands executed in Linux environments

Used the install.sh and uninstall.sh scripts available in the PR itself:

# Regular interactive installation:
curl -fsSL https://raw.githubusercontent.com/unslothai/unsloth/0d0425c8c49dbbc88a444944af51b59782734e37/install.sh | sh

# Installation with `--no-browser` option already set by command argument to the installer:
curl -fsSL https://raw.githubusercontent.com/unslothai/unsloth/0d0425c8c49dbbc88a444944af51b59782734e37/install.sh | sh -s -- --no-browser

# Installation with `--browser` option already set by command argument to the installer:
curl -fsSL https://raw.githubusercontent.com/unslothai/unsloth/0d0425c8c49dbbc88a444944af51b59782734e37/install.sh | sh -s -- --browser

# Installation with `--shortcuts-only --no-browser` options already set by command argument to the installer:
curl -fsSL https://raw.githubusercontent.com/unslothai/unsloth/0d0425c8c49dbbc88a444944af51b59782734e37/install.sh | sh -s -- --shortcuts-only --no-browser

# Installation with `--shortcuts-only --browser` options already set by command argument to the installer:
curl -fsSL https://raw.githubusercontent.com/unslothai/unsloth/0d0425c8c49dbbc88a444944af51b59782734e37/install.sh | sh -s -- --shortcuts-only --browser

# Regular uninstallation:
curl -fsSL https://raw.githubusercontent.com/unslothai/unsloth/0d0425c8c49dbbc88a444944af51b59782734e37/scripts/uninstall.sh | sh

Commands executed in Windows 11 environment

Used the install.ps1 and uninstall.ps1 scripts available in the PR itself:

# Regular interactive installation:
irm https://raw.githubusercontent.com/unslothai/unsloth/0d0425c8c49dbbc88a444944af51b59782734e37/install.ps1 | iex

# Installation with `--no-browser` option already set by command argument to the installer:
iex "& { $(irm https://raw.githubusercontent.com/unslothai/unsloth/0d0425c8c49dbbc88a444944af51b59782734e37/install.ps1) } --no-browser"

# Installation with `--browser` option already set by command argument to the installer:
iex "& { $(irm https://raw.githubusercontent.com/unslothai/unsloth/0d0425c8c49dbbc88a444944af51b59782734e37/install.ps1) } --browser"

# Installation with `--shortcuts-only --no-browser` options already set by command argument to the installer:
iex "& { $(irm https://raw.githubusercontent.com/unslothai/unsloth/0d0425c8c49dbbc88a444944af51b59782734e37/install.ps1) } --shortcuts-only --no-browser"

# Installation with `--shortcuts-only --browser` options already set by command argument to the installer:
iex "& { $(irm https://raw.githubusercontent.com/unslothai/unsloth/0d0425c8c49dbbc88a444944af51b59782734e37/install.ps1) } --shortcuts-only --browser"

# Regular uninstallation:
irm https://raw.githubusercontent.com/unslothai/unsloth/0d0425c8c49dbbc88a444944af51b59782734e37/scripts/uninstall.ps1 | iex

Important

Notice how the commands with arguments are different from the ones without them!
They are based on the explanations given in this particular answer to this Stack Overflow question.

Results

Overall, the new "no-browser" feature works as expected but with the following minor issues:

  • After the installer starts the server, the default browser is NOT auto-opened into Unsloth Studio when the "open browser" feature is left enabled.

  • On Linux environments, the commands with the --shortcuts-only option work but report a curl error in their output:

    $ curl -fsSL https://raw.githubusercontent.com/unslothai/unsloth/0d0425c8c49dbbc88a444944af51b59782734e37/install.sh | sh -s -- --shortcuts-only --no-browser
    
      🦥 Unsloth Studio Installer
      ────────────────────────────────────────────────────
    
      platform       linux
                    Created Unsloth Studio shortcut
    curl: (23) Failure writing output to destination

    The desktop shortcuts work and the variable STUDIO_OPEN_BROWSER is correctly updated, so I don't know what that curl error is truly reporting about.

…ser open

Three fixes from PR review and field testing:

- Forward an explicit --no-browser/--browser choice into the WSL Strix
  Halo reroute so the rerouted install honors the flag.
- Drain piped stdin before the --shortcuts-only early exit so
  curl | sh -s -- --shortcuts-only no longer dies with curl error 23.
- Open the browser after the installer's own foreground launch when the
  preference is on: a background watcher polls /api/health, verifies
  the per-install studio_root_id so a different Studio on the port is
  never opened, then opens the URL once. Mirrored in install.ps1 with a
  Start-Job watcher. When the preference is off nothing changes; the
  server already prints its URL.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

Thanks for the thorough field test across Kubuntu, Mint, and Windows 11, and for the correct piped-argument invocations. Both findings were reproducible and are fixed in 86200cb:

  1. Browser now opens after the installer's own launch. The "Start Unsloth Studio now?" path execs the server directly and never had any browser-open logic (that lived only in the desktop launcher), which is why nothing opened even with the feature enabled. The installer now starts a small background watcher before launching: it polls /api/health, verifies the per-install studio_root_id so a different Studio already sitting on port 8888 is never the one opened, then opens the URL exactly once. Same behavior on Windows via a Start-Job watcher in install.ps1. With the preference off, nothing extra happens; the server still prints its URL for PWA use.

  2. The curl (23) error on --shortcuts-only is gone. The shortcuts-only path exits early while curl is still streaming the rest of the script into sh, so curl died with EPIPE. That also made the whole curl | sh pipeline exit non-zero under pipefail even though the shortcuts were written correctly. The early exit now drains piped stdin first (skipped when stdin is a terminal). Reproduced the error locally with a file:// pipe, confirmed the fix removes it and that reverting the drain brings it back.

Also forwarded explicit --no-browser/--browser flags into the AMD WSL distro reroute per the other review note. Full simulation suites re-ran green (162 checks) plus the parity and installer-shape pytest guards.

@ehlesp

ehlesp commented Jul 10, 2026 •

Copy link
Copy Markdown

@shimmyshimmer, I've tested in the same environments the fixes for the issues I reported.

Testing Environments

  • Kubuntu 24.04, with KDE Plasma 5.27 as desktop.

  • Linux Mint 22.3 "Zena", with Cinnamon 6.6 as desktop.

  • Windows 11.

Commands executed in Linux environments

Used the fixed install.sh script available in the PR itself, also the uninstall.sh script for cleaning up:

# Regular interactive installation:
curl -fsSL https://raw.githubusercontent.com/unslothai/unsloth/86200cb0bef9fc9ce55fc37b78048cc70a83ef4a/install.sh | sh

# Installation with `--no-browser` option already set by command argument to the installer:
curl -fsSL https://raw.githubusercontent.com/unslothai/unsloth/86200cb0bef9fc9ce55fc37b78048cc70a83ef4a/install.sh | sh -s -- --no-browser

# Installation with `--browser` option already set by command argument to the installer:
curl -fsSL https://raw.githubusercontent.com/unslothai/unsloth/86200cb0bef9fc9ce55fc37b78048cc70a83ef4a/install.sh | sh -s -- --browser

# Installation with `--shortcuts-only --no-browser` options already set by command argument to the installer:
curl -fsSL https://raw.githubusercontent.com/unslothai/unsloth/86200cb0bef9fc9ce55fc37b78048cc70a83ef4a/install.sh | sh -s -- --shortcuts-only --no-browser

# Installation with `--shortcuts-only --browser` options already set by command argument to the installer:
curl -fsSL https://raw.githubusercontent.com/unslothai/unsloth/86200cb0bef9fc9ce55fc37b78048cc70a83ef4a/install.sh | sh -s -- --shortcuts-only --browser

# Regular uninstallation:
curl -fsSL https://raw.githubusercontent.com/unslothai/unsloth/86200cb0bef9fc9ce55fc37b78048cc70a83ef4a/scripts/uninstall.sh | sh

Commands executed in Windows 11 environment

Used the fixed install.ps1 script available in the PR itself, also the uninstall.ps1 script for cleaning up:

# Regular interactive installation:
irm https://raw.githubusercontent.com/unslothai/unsloth/86200cb0bef9fc9ce55fc37b78048cc70a83ef4a/install.ps1 | iex

# Installation with `--no-browser` option already set by command argument to the installer:
iex "& { $(irm https://raw.githubusercontent.com/unslothai/unsloth/86200cb0bef9fc9ce55fc37b78048cc70a83ef4a/install.ps1) } --no-browser"

# Installation with `--browser` option already set by command argument to the installer:
iex "& { $(irm https://raw.githubusercontent.com/unslothai/unsloth/86200cb0bef9fc9ce55fc37b78048cc70a83ef4a/install.ps1) } --browser"

# Installation with `--shortcuts-only --no-browser` options already set by command argument to the installer:
iex "& { $(irm https://raw.githubusercontent.com/unslothai/unsloth/86200cb0bef9fc9ce55fc37b78048cc70a83ef4a/install.ps1) } --shortcuts-only --no-browser"

# Installation with `--shortcuts-only --browser` options already set by command argument to the installer:
iex "& { $(irm https://raw.githubusercontent.com/unslothai/unsloth/86200cb0bef9fc9ce55fc37b78048cc70a83ef4a/install.ps1) } --shortcuts-only --browser"

# Regular uninstallation:
irm https://raw.githubusercontent.com/unslothai/unsloth/86200cb0bef9fc9ce55fc37b78048cc70a83ef4a/scripts/uninstall.ps1 | iex

Important

Notice how the commands with arguments are different from the ones without them!
They are based on the explanations given in this particular answer to this Stack Overflow question.

Results

  • In Linux environments, the fixed install.sh script:

    • Auto-opens the default browser into Unsloth Studio if the feature is left enabled in the installer question or with the --browser argument.
    • Does not auto-open the default browser into Unsloth Studio when the feature is disabled in the installer question or with the --no-browser argument.
    • Does not return a curl error with the --shortcuts-only argument.
  • In Windows 11, the fixed install.ps1 script:

    • Auto-opens the default browser into Unsloth Studio if the feature is left enabled in the installer question or with the --browser argument.
    • Does not auto-open the default browser into Unsloth Studio when the feature is disabled in the installer question or with the --no-browser argument.

@shimmyshimmer

Copy link
Copy Markdown
Member Author

Thank you for re-testing all three fixes across Kubuntu, Mint, and Windows 11. That matches what the simulation suites and CI show on this end: 55 checks green on 86200cb, including the macOS install matrix, the Windows update and installer round-trips, and the Linux run of the launcher test suite.

Recapping the final behavior now that it is field-verified on both platforms:

  • Installer question, --browser, or a saved preference of on: the browser opens once after the server is healthy, and only for this install (the watcher checks the per-install id before opening).
  • Installer question answered n, --no-browser, or UNSLOTH_STUDIO_NO_BROWSER=1: the server starts and the URL is printed instead, which covers the PWA app-window workflow that started this.
  • --shortcuts-only flips the stored preference on an existing install without reinstalling, and no longer trips the curl (23) error when piped.
  • Reruns of the installer and unsloth studio update keep the saved choice; Enter at the prompt never flips it.

Nothing outstanding on my side. Marking this ready to merge.

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

…s test

Addresses the two open review items, plus one leak found while confirming them.

UNSLOTH_SKIP_AUTOSTART is documented for automated installs, but the new browser
prompt did not check it: under `curl ... | sh` only stdin is the pipe, so [ -t 1 ]
is still true and the prompt blocked an install that previously ran unattended.
Both installers now gate it exactly as they gate the launch prompt below it.
Reproduced under a real pty before and after, and pinned by two assertions that
are absent at the previous head.

tests/sh/test_launcher_no_browser.sh stubbed only open and xdg-open, but
_open_browser prefers powershell.exe then cmd.exe on WSL, so running the suite on
a WSL machine opened a real browser window and then failed on the empty recorder.
All four openers are stubbed, PATH is pinned to them plus coreutils, and
/proc/version is a fixture, so one Linux runner now covers every rung of the WSL
ladder and the no-opener fallback.

The post-install watcher also outlived the installer: its pid was never kept, so
Ctrl-C on the foreground server left it polling out its 120s deadline and it
could open a browser after the install had visibly finished. It is now reaped
once the server exits, and the PowerShell job is stopped and removed in a
finally, matching what install.ps1 already does for its other Start-Job. The
watcher no longer treats a missing studio_install_id as "any backend will do".
# Conflicts:
#	.github/workflows/studio-backend-ci.yml
#	README.md
#	install.sh
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 6, 2026
@unslothai unslothai deleted a comment from shimmyshimmer Aug 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 6, 2026
@unslothai unslothai deleted a comment from shimmyshimmer Aug 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 6, 2026
danielhanchen added a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Aug 6, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 1f806ebb5d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@danielhanchen
danielhanchen merged commit 3860d69 into main Aug 6, 2026
63 of 85 checks passed
@danielhanchen
danielhanchen deleted the launcher-no-browser branch August 6, 2026 11:51
danielhanchen added a commit that referenced this pull request Aug 6, 2026
danielhanchen added a commit that referenced this pull request Aug 7, 2026
* Fail CI on new yes/no prompts in the installers

#7016 added an "Open Unsloth Studio in your default browser after
launch? [Y/n]" question to the interactive install and had to be
reverted in #8040. Nothing stopped it landing, so add an allowlist
guard over install.sh, install.ps1, studio/setup.{sh,ps1} and
scripts/uninstall.{sh,ps1}.

Two text passes per script: literal [Y/n] markers, and interactive
read sites (read off /dev/tty or -p, Read-Host, PromptForChoice,
ReadKey). The second is what catches #7016's shape, where the marker
was assigned to _browser_hint a line above the printf.

Findings are keyed by normalised question text rather than line
number, and checked against APPROVED_PROMPTS, which holds the four
prompts in the tree today: "Start Unsloth Studio now?" on both
installers, plus the two elevation consent prompts in install.sh and
studio/setup.sh. Anything else fails with the file, line, question
and the exact allowlist line to add if the prompt is intended, so
the decision lands in the diff instead of in the installer unnoticed.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Scan the helper installers and fix the read -p detection

Two review findings on the prompt guard.

install.sh downloads and runs scripts/install_rocm_wsl_strixhalo.sh on
the automatic WSL path, with no TTY, so a question added there stalls a
piped install exactly like the one this guard exists to stop. Scan the
scripts/install*.sh helpers as well, and widen the coverage glob so the
next one has to be registered too. All three are prompt-free today, so
the allowlist is unchanged.

The read pass also missed `read -p "Q "` and `read -rp "Q "`: `read\s+`
ate the only space, leaving nothing for the whitespace anchor in front
of `-p`, so only the two-token `read -r -p` form matched. Match `-p` as
an option word instead, bundled or not. The existing test passed on a
fixture that carried a literal [Y/n], which the marker pass caught, so
the broken branch was masked; the new cases have no marker. Bounding
the scan at ; | & at the same time stops a `mkdir -p` later on the line
being read as a prompt.

* Tighten the comments on the prompt guard

* Derive the scanned helpers from the installers themselves

studio/setup.sh:2461 runs scripts/build_whisper_cpp.sh when the prebuilt
whisper.cpp is unavailable, under run_quiet_no_exit, where a question
would hang with its own prompt swallowed. Scan it.

Naming helpers by hand only ever covers the ones we thought of, which is
how this one and the WSL bootstrap were both missed, so read them back
out of the entry points instead: every scripts/*.sh or .ps1 an installer
or setup script references now has to be in SCANNED_SCRIPTS. Those two
are the only ones today, and both are prompt-free, so the allowlist is
unchanged.

Also detect [Console]::ReadLine() and ReadKey in the PowerShell pass.
They block exactly like Read-Host and can take their question from a
variable, out of the marker pass's reach. Neither installer reads that
way today and no [Console]:: write site matches, so the baseline scan is
unchanged.

* Follow helper references transitively, and glob scripts/install*.ps1

The reference check only read the four entry points, so a helper that
grows a helper of its own was invisible. Every scanned script is a
source now, which closes over the whole chain: once the first helper is
listed, whatever it reaches has to be listed too.

The static globs also covered scripts/install*.sh but not the PowerShell
half, so a standalone scripts/install_windows.ps1 that no entry point
references would not have been required in SCANNED_SCRIPTS.

Both leave the scanned set as it is today, so the allowlist and the
baseline scan are unchanged.

* Catch bare reads, console reads and branch questions

Five gaps from review, none of which changes what the scan finds in the
tree today.

The read pass only knew about -p and /dev/tty, so the commonest prompt
of all, a question printed with no marker and answered by a plain
unredirected read, went straight through. An unredirected read takes the
terminal the installer inherited, so it blocks the same way. Loop and
pipeline reads are fed by their done or their pipe, and the shape is
pinned to options then variable names at end of line in command
position, so the word read in a heredoc of prose is not mistaken for one.

A read site now validates every question in reach rather than only the
nearest. One read can serve a branch each, and approving the closest was
enough to wave the other branch through under an allowlisted key.

PowerShell: [Console]::Read() joins ReadLine and ReadKey, and <# ... #>
blocks are blanked. studio/setup.ps1 opens with comment-based help, so a
documented Read-Host example there would have failed CI over a prompt
that cannot run.

Helper references no longer need the scripts/ prefix, since helpers
invoke each other out of their own directory. A name only counts once it
resolves to a real script beside the one naming it or in scripts/, so a
filename mentioned in a message is still ignored.

* Stop the read pass tripping over quotes, fallbacks and interpolation

Five more from review, all of them shapes the previous round created or
left behind. The scan of the tree is unchanged.

Two were my own false positives. Excluding any line containing a pipe
threw out `read -r reply || reply=n`, which is the house style for an
EOF default and still blocks; only a real pipeline counts now. And the
PowerShell pass matched an API name anywhere on the line, so a message
saying Read-Host is unavailable read as a prompt. Quoted text is blanked
before the read test, which also covers a single-line <# ... #> block,
where the previous state machine only handled an opener and closer on
different lines.

Normalising away every substitution meant printf "Start Unsloth Studio
%s now?" keyed as the approved question. Substitutions become a
placeholder instead, so spliced wording is a new question, while one at
the end still normalises away since that is the marker hint the other
pass already read.

select is the other builtin that blocks for an answer, and its PS3
question is picked up by the existing nearby scan.

* Glob the workflow paths, and widen read and helper matching

The coverage check refuses an unregistered root installer, but the
workflow enumerated filenames, so adding install_linux.sh would not have
run the check that rejects it. Its paths are globs now, which is also
shorter than the list it replaces.

Bare reads accept option arguments, so read -r -n 1 reply and
read -r -t 10 reply count: a one-character or timed confirmation is
still a confirmation. $Host.UI.ReadLine joins the console reads, kept
anchored so a StreamReader over a file is not mistaken for a prompt.

Helper references keep their subdirectory and are resolved by full path
as well as by name, so a nested helper is found while a URL still
resolves to the local copy. The lookbehind keeps a leading $VAR out of
the captured path.

The scanned set, the allowlist and the scan of the tree are all
unchanged.

* Scan the Python helpers and the batch launcher

studio/setup.sh runs four helpers with `python <helper>.py`, the first
being install_python_stack.py at setup.sh:1010, and studio/setup.bat is
the Windows launcher. An input() or a set /p in any of them blocks the
same Studio update, so scan them: input, getpass and confirm for Python,
set /p and choice for batch, with REM and :: treated as comments.

Helper references follow .py and .bat now, but only out of shell,
PowerShell and batch scripts. A shell script naming a file runs it, a
Python file naming one imports it, and following imports walked straight
into unsloth/models/_utils.py, which is library code, not an installer.

Also: `IFS= read -r reply` is one command, not an assignment, so leading
assignments are allowed before read; and a `#>` terminator sharing its
line with code no longer blanks the code.

All five newly scanned files are prompt-free, so the allowlist and the
scan of the tree are unchanged.

* Read strings, docstrings and command position more carefully

Six from review. Three are false positives or blind spots the previous
round's own fixes created.

Blanking quoted text to stop a message naming Read-Host from reading as
a prompt also blanked $(...) subexpressions, which execute: PowerShell
prompts from inside an expandable string. Those are kept now, and a
string quoted inside one is offered as the question, so the site keys on
the real wording rather than an unlabelled read. Batch reads are matched
in command position only, so echoing the word choice in a message is not
a prompt. Python docstrings are blanked, keeping the line count, since
a documented input() example cannot run and the scanned helpers are full
of triple-quoted text.

read -r with no variable name is valid and puts the answer in $REPLY, so
the variable list is optional. Helper references accept backslashes and
normalise them, the tree already writing .\scripts\uninstall.ps1 that
way. Root install*.bat joins the discovery globs and the workflow paths,
for the same reason install_linux.sh did.

Scan of the tree is unchanged.

* Follow the Python installers, and stop three more false positives

Seven from review, one declined.

Three were mine. `confirm\s*\(` was unanchored, so an ordinary
`def confirm(value):` failed CI as an unlabelled read; only real
confirmation APIs count now. `_blank_strings` erased f-string fields
along with inert text, though a field executes exactly like the
PowerShell subexpression fixed last round, so both are kept and a string
quoted inside one is offered as the question. And a `read` in a loop
body whose redirection sits on the `done` three lines below looked
interactive, since the check only ever saw the read line; block bodies
with a redirected `done` are excluded now.

Python sources are traversed again. They were skipped because following
them walked into unsloth/models/_utils.py, but that reference is in a
comment and the ones like it are in docstrings, so blanking those fixed
the cause. install_python_stack:4157 runs patch_metadata.py with
sys.executable, and that path is built from a variable, so it is listed
rather than discovered. studio/install_*.py is globbed, which covers
install_sd_cpp_prebuilt.py and install_manifest.py.

Also: a read can be the condition of an `if`, sys.stdin.read and
readline block like input(), and `@` in batch suppresses the echo of a
command without stopping it running.

Declining repo-wide resolution of a helper by basename: it picks up
sitecustomize.py and build artifacts. The scan of the tree is unchanged.

* Blank heredocs, and stop reading an output pipe as loop input

Six from review, two of them mine.

`done | tee install.log` pipes the loop's output, not its input, so its
reads still take the terminal. Only an input redirection excludes a loop
body now. A triple-quoted f-string was blanked as a docstring even though
its fields execute, so an f prefix keeps the line.

Heredoc bodies are blanked, keeping the line count. That is what makes
the rest safe: a bare read may now be followed by another command, which
without this would have flagged the read -r reply in the uninstaller's
help text. Writing that turned up a worse bug in my own first attempt at
it. The heredoc opener matched the `<<<` here-string inside install.sh's
printed profile marker, so everything after line 3424 was blanked and
the sanctioned Start Unsloth Studio prompt disappeared from the scan. The
allowlist-still-exists check caught it. `<<<` is excluded and openers are
read from code rather than from inside strings.

Also: getpass imported directly, and batch prompts as the body of a
single-line if. The scan of the tree is unchanged, and replaying it over
the last 25 revisions of the five main scripts finds no false positive
and never loses a known prompt.

* Judge strings, pipes and redirections per language and per command

Nine from review, three declined.

The heredoc handling gets a structural backstop rather than another
patch: an opener is read from code with inline comments removed, and an
opener whose terminator never arrives now blanks nothing at all.
Blanking to end of file is the failure mode that silently blinds the
scan for everything after it, which is what the <<< here-string did last
round, so it should not be reachable by any opener at all.

Three were mine. Keeping a string because it contained $( or a brace
field ignored the quote type, so a PowerShell single-quoted diagnostic
or a plain Python string with code-shaped text survived blanking and
read as a prompt; expansion is judged per language now. The pipeline
test looked at the whole line, so the pipe in read -r reply; echo done |
tee log was attributed to the read, and the bare-read path runs per
command. A loop is only excluded when its done redirects stdin, not when
it opens a spare descriptor such as done 3<config.

The rest: set /p version=<VERSION.txt reads a file, sys.stdin.buffer
reads block like sys.stdin, read option arguments may be fractional or
quoted, and install*.py plus studio/setup*.sh and .ps1 join the globs
and the workflow paths.

Declined: occurrence counts for duplicate approved wording and dropping
the trailing-substitution rule, both of which trade a shape nobody
writes for allowlist churn on ordinary edits, and resolving helper paths
assembled in variables, which needs the text evaluated rather than read.

Replaying the scan over the last 25 revisions of ten scanned files, 250
file revisions in all, finds no false positive and never loses a known
prompt.

* Check the workflow filters against the scanned set

Five from review, one declined.

A comment naming a delimiter was read as one, in Python and in
PowerShell, which blanks the rest of the file and takes every prompt in
it out of the scan. Comments are removed before either delimiter is
interpreted, and both get the backstop the heredoc opener already has:
an unterminated docstring or block comment puts its lines back rather
than blanking to end of file. This is the third language where reading a
delimiter out of text went the same way, so the backstop matters more
than the individual fix.

The workflow filters are now read back and matched against
SCANNED_SCRIPTS, instead of two lists kept in step by hand. Without it a
registered helper is only ever checked on the PR that registers it, and
a later PR touching only that helper runs nothing. Parsed with a regex
since the parity runner installs pytest alone. Root uninstall*.sh and
uninstall*.ps1 join the globs, and a bare read may carry a trailing
comment.

Declining prompt labels with no question mark. A literal
`Enable telemetry [Y/n]` is already caught by the marker pass; what is
left is a label whose marker lives in a variable, and admitting those
means treating every nearby message as a candidate key, which churns the
allowlist on ordinary edits.

Replaying the scan over the last 25 revisions of all 18 scanned scripts,
450 file revisions, finds no false positive and loses no known prompt.

* Treat a batch pause as a blocking prompt

It asks nothing, but an unattended install stops dead on it just as it
would on set /p, and pause is a batch builtin rather than an external
program, which is where I drew the line earlier in this review.

* Check each workflow event, and stop blanking interpreter heredocs

Four from review, one declined.

The workflow-filter check I added last round collected quoted entries
from the whole file, so a script present only in the push filter would
have passed it while pull requests ran nothing. Each event's block is
read and required to cover the scanned set on its own.

An interpreter heredoc such as `python - <<PY` runs its body, so
blanking it hides real code, which is worse than reading it as shell:
the marker pass still sees the body this way. Documentation heredocs are
blanked as before.

Also: `if ! read -r reply` counts, `if ! cmd` being house style in these
scripts already, and root uninstall*.bat and uninstall*.py join the
globs and the workflow paths now that both languages are scanned.

Declining local Python imports. install_whisper_prebuilt importing
prebuilt_core is library composition, not an invocation, and following
imports has no natural stop: it reached unsloth/models/_utils.py the
first time, which is core library code and not an installer. The line
stays where it was, at what a script runs.

* Scope redirections to their own command, and blank literal here-strings

Five from review, one declined. Four are corrections to my own recent
changes rather than new ground.

Excluding a file-fed loop body suppressed every read in it, including an
explicit `read -r reply </dev/tty` that overrides the loop's stdin and
still waits on the user. Only the bare-read path is suppressed there
now. The batch check discarded a whole line containing any `<`, so
`choice ... & set /p v=<VERSION.txt` lost its prompt; the redirection
belongs to its own command, as it already did for shell. The workflow
filter check ignored `!` patterns, which GitHub applies in order, so an
exclusion added later would have passed it unnoticed.

PowerShell literal here-strings are blanked. `@' ... '@` cannot expand,
and this is live rather than theoretical: scripts/uninstall.ps1 prints
its help from one and install.ps1 embeds source in the expandable form.
Expandable `@" ... "@` is left alone, since it does run.

Root setup*.sh, .ps1 and .bat join the globs and both workflow filters.

Declining scanning an interpreter heredoc body in the interpreter's own
language, as last round. Not blanking it is the part that mattered, so
real code is never hidden; a full multi-language embedded scan is a
different tool.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
danielhanchen added a commit that referenced this pull request Sep 6, 2026
… encoding

Three CI guards were failing on this branch and all three were pointing at real
problems for users who are not on this hardware.

install.sh had grown a question. `Set up the second Spark now? [y/N]` was behind
a tty check, so a `curl ... | sh` install could not stall on it, but the rule the
guard enforces is not only about stalling: an answer given once during install is
one the user cannot find again afterwards, which is what #7016 did and #8040
reverted. The setting was already an environment variable, UNSLOTH_SPARK_CLUSTER,
with a non-interactive default of no, and the skip path already printed how to do
it later. So the prompt is removed and nothing is lost: with the variable set the
setup runs as before, and without it the installer says how to pair the machines
afterwards instead of asking.

Thirteen text reads and writes in shipping code let the operator's locale pick the
encoding, and three more in the test tree read checked-in files the same way. On
Windows that is mojibake or a crash the moment any of those files gains a non-ASCII
byte, and several of them read llama-server logs and adapter configs, which is
exactly where a non-ASCII byte turns up first. All of them now pass
encoding = "utf-8". No behaviour changes on Linux or macOS, where utf-8 was already
the default.

tests/test_installer_interactive_prompts.py 92 passed, test_runtime_text_encoding
and test_source_read_encoding pass, and test_spark_serving, test_spark_router and
test_spark_offbox are 170 passed / 41 skipped. ruff clean on the Python files,
bash -n clean on install.sh.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants