Skip to content

harden install/run: flags, preflight report, offline pip, port-in-use#9

Merged
StewAlexander-com merged 1 commit into
mainfrom
harden-install-run
May 19, 2026
Merged

harden install/run: flags, preflight report, offline pip, port-in-use#9
StewAlexander-com merged 1 commit into
mainfrom
harden-install-run

Conversation

@StewAlexander-com
Copy link
Copy Markdown
Owner

Summary

Real-world install on a fresh Mac surfaced several quiet failure modes
the previous scripts handled poorly: an off-by-one Python version
parser, an opaque `pip` failure on a network that couldn't resolve
PyPI, a venv that broke after the repo was moved, and no way to pick a
different port when 8001 was in use. This PR makes the obvious failures
fail loudly with a concrete next step, exposes the previously
env-var-only options as proper `--flags`, and adds a runbook that
captures the audit.

  • `install.sh` and `run.sh` now take `--help` and a real flag set
    (`--yes`, `--noninteractive`, `--no-launch`, `--skip-ollama`,
    `--model`, `--host`, `--port`, `--open-browser`). Flags are sugar
    over the existing env vars; nothing pre-existing breaks.
  • `install.sh` prints a one-screen preflight report, parses Python
    versions correctly (the old `${ver##*.}` mis-read patch as minor on
    any 3-component version), and rebuilds the venv automatically if the
    repo has been moved since the venv was created.
  • On `pip` failure, the script tails the captured log and -- if the
    log shows DNS/network signatures -- prints offline-wheelhouse,
    proxy, and internal-mirror recipes.
  • `run.sh` probes the target port with `/dev/tcp` (no new deps) and
    exits 4 with `--port N` guidance rather than letting uvicorn fall
    over. `--open-browser` polls `/api/health` and opens once healthy.
  • `scripts/smoke_flags.sh` exercises `--help`, unknown-flag
    rejection, `--no-launch`, and the port-in-use path. Wired into CI.
  • README gains a concise 'Install reliability' table; the detailed
    audit and runbook live in `docs/install-audit.md`.

Test plan

  • `shellcheck -x install.sh run.sh scripts/*.sh` clean
  • `./install.sh --help` and `./run.sh --help` exit 0 with full
    flag list
  • `./install.sh --noninteractive --skip-ollama --skip-model-pull
    --no-launch` completes without prompting
  • `./install.sh --bogus` exits 3 with `unknown option` message
  • `./run.sh --no-launch --skip-ollama --port 8902` preflights and
    exits 0 without binding
  • `./run.sh --skip-ollama --port ` exits 4 with port-in-use
    message
  • `scripts/smoke_run.sh` -- `/api/health` and `/` reachable
  • `scripts/smoke_prompts.sh` -- y/N paths preserved
  • `scripts/smoke_flags.sh` -- new flag suite green
  • `backend/.venv/bin/pytest -q backend` -- 89 passed

🤖 Generated by Computer

…in-use

install.sh:
- accepts -h/--help, -y/--yes, -n/--noninteractive, --no-launch,
  --skip-ollama, --skip-model-pull, --model TAG; flags are sugar over
  the existing env vars and never override an explicit env setting
- prints a one-screen preflight report (OS, Python, Ollama state, model,
  mode) before any host-mutating step
- fixes the Python version parser, which silently misread the patch
  component as 'minor' on three-component versions like 3.10.0 / 3.14.4
- tracks the repo path inside backend/.venv/.tutor_repo_root and rebuilds
  the venv automatically if the repo has been moved (virtualenvs are
  path-sensitive)
- captures pip output to a log file and prints offline / proxy /
  wheelhouse remediation when the log shows DNS or network failure
- documents exit codes (0/1/2/3)

run.sh:
- accepts -h/--help, --host, --port, --model, --open-browser,
  --no-launch, --skip-ollama, -y, -n; equivalent env vars still work
- probes the target port with /dev/tcp before exec'ing uvicorn and exits
  4 with an actionable message if a listener is already bound (no new
  system deps -- no lsof/ss)
- --open-browser polls /api/health and only opens the URL once healthy
- --no-launch runs the full preflight (venv, Ollama probe, port check)
  without binding a socket, useful for CI

docs:
- README gains an 'Install reliability' table linking to the new audit
- docs/install-audit.md is the detailed runbook (offline wheelhouse,
  proxy, venv path sensitivity, gh auth)
- docs/install-runtime-workflow.md grows a CLI-flag table, the offline
  /restricted-network section, and a venv-relocation note

tests:
- scripts/smoke_flags.sh exercises --help, unknown-flag rejection,
  --no-launch, and port-in-use detection
- CI runs the new smoke step alongside the existing ones
@StewAlexander-com StewAlexander-com merged commit 9341eb1 into main May 19, 2026
5 checks passed
@StewAlexander-com StewAlexander-com deleted the harden-install-run branch May 19, 2026 18:42
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.

2 participants