WSL port 1/7: say what is missing, then offer to install it

Merged
JA
3mo ago
+238-12

Stacked on #6. Review that one first — this PR's diff is against wsl/00-todo.

The problem

The old dependency check was three command -v lines and a version gate. It
caught the two things that make drill fail loudly and none of the things that
make it fail quietly — which on Linux and WSL is most of them. A box with no
clipboard provider installs cleanly and then makes Ctrl+V over a selection
delete the selection and paste nothing, with no warning at any point.

What it does now

Probe what each documented feature actually needs, name what is missing in terms
of what it costs you, print the exact install line for the detected package
manager, and ask before running it. --yes skips the asking; a non-tty stdin
never asks. After an install it re-runs the probes rather than trusting the
package manager's exit code.

Three things it refuses to guess at

neovim on apt. Ubuntu 22.04's candidate is 0.6.1, which the 0.9 gate then
rejects — the old hint literally sent you to install a version this same script
refuses. It now asks apt what its candidate is and offers it only when it is new
enough, otherwise pointing at snap or the AppImage.

python3 on WSL. WSL appends the Windows PATH, so with no Linux python
installed python3 resolves to the Store alias under WindowsApps, which opens
the Microsoft Store instead of running your file. That passes command -v and
dies inside a 15-row split, so the resolved path gets checked.

sound and notifications. Measured on this box (Ubuntu 22.04 under WSLg):

$ pw-play .../alarm-clock-elapsed.oga
remote error: id=3 seq:7 res:-2 (No such file or directory): no node available
pw-play exit=1

$ notify-send drill test
GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown:
  The name org.freedesktop.Notifications was not provided by any .service files

Both are installed and both fail — WSLg ships no notification daemon.
Presence is not proof, so this check only claims there is something to try, and
counts powershell.exe as that something on WSL. Making the timer believe the
exit code is checkpoint 3's job.

Also fixed

[ "$x" -eq 0 ] on a non-numeric field is fatal under set -e, so the version
check could abort the install instead of passing it. Verified against the
original code:

versionbeforeafter
0.9.5, 0.10.2, 0.11.0-dev-1234+gabcdef, 0.12.4-Homebrewokok
0.10-dev[: integer expression expectedok
NVIM 0.9.5 (no v prefix to strip)[: integer expression expectedok

Verification

  • bash -n install.sh
  • clean run into an isolated HOME — exit 0, rc block written, files copied
  • non-tty run — prints the command, runs nothing, says why
  • --yes run — detected libnotify-bin missing, installed it, re-probed
  • version gate driven with a stub nvim across the six strings in the table above; 0.6.1 is the only one rejected

Not covered here: the clipboard fallback itself (checkpoint 2) and the timer
chain (checkpoint 3). This PR only makes their absence visible.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WveBqAyhoM49p9gWfwBDBx

Summary by CodeRabbit

  • New Features
    • Added --yes/-y, --uninstall, and --help command-line options.
    • Expanded compatibility checks across Linux, macOS, and WSL.
    • Added detection and reporting for required and optional system tools.
    • Added support for generating installation commands through recognized package managers.
    • Added automatic dependency installation with verification before proceeding.
    • Installation now stops when required dependencies are unavailable while allowing optional features to remain unsupported.

Greptile Summary

This PR replaces the minimal dependency checks with platform-aware capability probes, package-manager-specific installation offers, and post-install verification.

  • Adds --yes, --uninstall, and help argument handling.
  • Detects hard requirements and optional feature dependencies across macOS, Linux, and WSL.
  • Generates package installation commands and re-runs probes after installation.
  • Makes Neovim version parsing tolerate development and vendor-suffixed versions.

Confidence Score: 4/5

The PR should not merge until the outstanding sound capability mismatch is resolved at the intended merge point.

The installer currently treats pw-play or aplay as usable sound support, but the timer only invokes afplay and paplay, leaving affected Linux installations without the offered dependency fix and producing only the terminal bell.

Files Needing Attention: install.sh, drill.sh

Important Files Changed

FilenameOverview
install.shAdds cross-platform dependency probing, optional package installation, argument parsing, and resilient Neovim version validation.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Parse installer options] --> B[Detect OS, WSL, and package manager]
  B --> C[Probe hard and feature dependencies]
  C --> D{Anything missing?}
  D -->|No| H[Install drill files and shell configuration]
  D -->|Yes| E[Report unavailable capabilities]
  E --> F{Known packages and installation approved?}
  F -->|Yes| G[Run package command and probe again]
  F -->|No| I{Hard dependency missing?}
  G --> I
  I -->|Yes| J[Abort installation]
  I -->|No| H

Reviews (6): Last reviewed commit: "Drop the head -1 pipeline that could abo..." | Re-trigger Greptile