Skip to content

Revert "Add option to launch Studio without opening the default browser" - #8040

Merged
danielhanchen merged 1 commit into
mainfrom
revert-7016-launcher-no-browser
Aug 6, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
revert-7016-launcher-no-browser

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Reverts #7016

@danielhanchen
danielhanchen merged commit c2a91db into main Aug 6, 2026
17 of 30 checks passed
@danielhanchen
danielhanchen deleted the revert-7016-launcher-no-browser branch August 6, 2026 15:39

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eaed39b98a

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

Comment thread install.sh
# early exit; otherwise curl dies with EPIPE, prints "curl: (23) Failure
# writing output to destination", and fails the whole pipeline.
[ ! -t 0 ] && cat > /dev/null 2>&1
exit 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep draining stdin before the shortcuts-only exit

When the installer is streamed as curl ... | sh -s -- --shortcuts-only, this early exit can close the pipe before the producer finishes writing the roughly 150 KB script. Curl then reports error 23 (Failure writing output to destination), and callers using pipefail treat an otherwise successful shortcut refresh as failed. The removed stdin drain was independent of browser-launch behavior and should remain before this exit.

Useful? React with 👍 / 👎.

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.

1 participant