Skip to content

install.sh: keep the studio launch from draining the curl | sh script (WSL/dash) - #6258

Merged
danielhanchen merged 1 commit into
mainfrom
install-fix-curl-sh-stdin-drain
Jun 12, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
install-fix-curl-sh-stdin-drain

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

Installing with curl -fsSL https://unsloth.ai/install.sh | sh can end with:

sh: 2913: Syntax error: end of file unexpected (expecting "fi")

The install itself completes (Studio installs, the prebuilt attaches), but the script dies right at the end. Reported on WSL, where /bin/sh is dash.

Cause

With curl | sh the shell reads the script from the pipe on stdin. The optional "Start Unsloth Studio now?" step launches unsloth studio in the foreground, and as a long-running server it inherits that same stdin. It drains the rest of the piped script, so the shell reaches EOF partway through the trailing if/case and reports unexpected end of file (expecting fi). dash -n passes because the file is syntactically valid, the breakage is purely runtime stdin consumption, which is why it shows up under dash (strict, reads incrementally) and not always under bash.

Fix

Redirect the launch's stdin away from the pipe (</dev/null) so the script stays intact for the shell to finish parsing. The server does not read stdin, and Ctrl+C still works through the controlling terminal.

Verification

  • dash -n install.sh and bash -n install.sh both pass.
  • Repro of the mechanism: a foreground reader that inherits the piped script drains its tail (the shell then dies parsing the unread fi); with the stdin redirect the tail is left untouched (0 bytes consumed) and the script finishes.

When installed via 'curl -fsSL https://unsloth.ai/install.sh | sh', the
shell reads the script from the pipe on stdin. The optional 'start now'
step launches 'unsloth studio' in the foreground, and as a server it
inherits and drains the rest of the piped script from stdin. The shell
then hits EOF partway through the trailing if/case and dies with
'Syntax error: end of file unexpected (expecting fi)' (reported on WSL,
where /bin/sh is dash). Redirect the launch's stdin away from the pipe so
the script stays intact. The server does not read stdin and Ctrl+C still
works via the controlling terminal.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the install.sh script to redirect standard input from /dev/null when launching Unsloth Studio. This prevents the foreground server from draining the remainder of the piped script when executed via curl | sh, which would otherwise cause a parsing error. There are no review comments, so I have no additional feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@danielhanchen
danielhanchen merged commit be2a122 into main Jun 12, 2026
25 checks passed
@danielhanchen
danielhanchen deleted the install-fix-curl-sh-stdin-drain branch June 12, 2026 14:35
danielhanchen added a commit that referenced this pull request Aug 3, 2026
…st (#7774)

* Anchor the host-defaults assertions and take the file off the skip list

test_install_host_defaults.sh has been quarantined since #7431 and failing for
longer, with a recorded reason that covers one of three drifts. None of them is
a regression: install.sh, install.ps1 and the README all still behave as the
test intends. Every failure comes from how the test carves out the text it
greps.

Both installers were sliced with a fixed tail. install.sh grew past its 50-line
window in #6258 and install.ps1 past its 25-line window in #7be1085, the day
after the test landed, so the prompt each assertion looks for sat just above the
window. Both now start at the block's own 'In interactive terminals' comment.

The README extractor stopped at a '#### Update' heading that was later deleted,
so its Launch section silently became the rest of the file and picked up the
-H 0.0.0.0 from the remote-access section 137 lines below. It now stops at the
next heading of any name.

Two assertions could not have failed. setup.sh's launch hint sits at line 2332
while tail -30 covered 2339 onward, so the negative check no longer looked at
the hint at all, and 'read' as a needle also matches 'readable' and
'_can_read_tty', so the prompt check passed with the prompt deleted. Both are
pinned to what they mean to protect; each of the six assertions now fails when
its target is removed.

With the extraction fixed the file passes 10/10, so it comes off the skip list
in run_all.sh, studio-backend-ci.yml and test_ci_shell_suite_coverage.py, which
have to change together.

* Give the setup.sh window a canary and stop at any heading level

The setup.sh launch-hint extraction was the only one of the four with no
positive assertion over it. The other three each pin something that must be
present, so a broken extraction fails loudly; this one had a lone
assert_not_contains, and a negative check over an empty window passes. Renaming
the printf label empties it, and the test then stays green with 0.0.0.0
hard-coded in the hint, which is the failure this PR exists to remove.

The README extractor's comment promised the next heading of any name while the
pattern only matched an h4, so demoting the following heading would widen the
window again.

* Tighten the comments on the anchored host-defaults assertions
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