#!/usr/bin/env bash # CrowdSharp One-Click macOS / Linux Setup (Lean 4.19.0 + Lean 4.36.0 + Slices Repo) # Usage: curl -sSfL https://crowdsharp.org/api/setup/unix.sh | bash set -euo pipefail INSTALL_DIR="${CROWDSHARP_DIR:-$HOME/crowdsharp-slices}" DEFAULT_TOOLCHAIN="${CROWDSHARP_TOOLCHAIN:-leanprover/lean4:v4.19.0}" echo "============================================================" echo " CrowdSharp Lean 4 Contributor Setup (macOS / Linux)" echo " https://crowdsharp.org | github.com/crowdsharp/slices" echo "============================================================" echo "" echo "[1/6] Checking git & curl..." for cmd in git curl; do if ! command -v "$cmd" >/dev/null 2>&1; then echo " ERROR: '$cmd' is required. Please install $cmd and re-run." exit 1 fi done echo " OK: $(git --version)" echo "" echo "[2/6] Checking elan (Lean 4 version manager)..." export PATH="$HOME/.elan/bin:$PATH" if ! command -v elan >/dev/null 2>&1; then echo " Installing elan from https://elan.lean-lang.org/elan-init.sh..." curl -sSf https://elan.lean-lang.org/elan-init.sh | sh -s -- -y --default-toolchain none export PATH="$HOME/.elan/bin:$PATH" fi echo " OK: $(elan --version)" echo "" echo "[3/6] Installing CrowdSharp Lean 4 toolchains (v4.19.0 Archive + v4.36.0 Frontier)..." for tc in "leanprover/lean4:v4.19.0" "leanprover/lean4:v4.36.0"; do echo " Installing $tc..." if elan toolchain install "$tc"; then echo " OK: Installed $tc" else echo " WARN: Could not install $tc (you can retry later with: elan toolchain install $tc)" fi done elan default "$DEFAULT_TOOLCHAIN" || true echo "" echo "[4/6] Setting up CrowdSharp slices workspace at $INSTALL_DIR..." if [ -d "$INSTALL_DIR/.git" ]; then git -C "$INSTALL_DIR" pull --ff-only echo " OK: Updated $INSTALL_DIR" else git clone https://github.com/crowdsharp/slices.git "$INSTALL_DIR" echo " OK: Cloned to $INSTALL_DIR" fi echo "" echo "[5/6] Checking for root Lakefile / Mathlib cache..." if [ -f "$INSTALL_DIR/lakefile.toml" ] || [ -f "$INSTALL_DIR/lakefile.lean" ]; then (cd "$INSTALL_DIR" && lake exe cache get) || echo " WARN: Run 'lake exe cache get' inside any individual slice folder." else echo " Individual slices carry their own lakefile; run 'lake exe cache get && lake build' inside any slice folder." fi echo "" echo "[6/6] Checking VS Code Lean 4 extension..." if command -v code >/dev/null 2>&1; then code --install-extension leanprover.lean4 || true echo " OK: VS Code Lean 4 extension installed." else echo " Optional: install VS Code (https://code.visualstudio.com/) and the 'leanprover.lean4' extension." fi echo "" echo "============================================================" echo " CrowdSharp Lean 4 Setup Complete!" echo "============================================================" echo " Lean: $(lean --version)" echo " Lake: $(lake --version)" echo " Workspace: $INSTALL_DIR" echo "" echo "Installed toolchains:" elan toolchain list echo "" echo "Next steps:" echo " 1. Browse 1,000 Mathlib-Bound specs at https://crowdsharp.org" echo " 2. Enter a slice folder: cd \"$INSTALL_DIR/slices//v4.19.0\"" echo " 3. Fetch Mathlib cache & verify: lake exe cache get && lake build && lake env lean4checker --fresh" echo " 4. Join Discord: https://discord.gg/HSksfsMCUc"