#!/bin/sh # Mu installer — downloads and runs Mu with one command. # Usage: curl -fsSL https://micro.mu/install.sh | sh set -e REPO="micro/mu" INSTALL_DIR="${MU_INSTALL_DIR:-$HOME/.mu}" BIN_DIR="${MU_BIN_DIR:-$HOME/.local/bin}" # Detect OS and architecture OS=$(uname -s | tr '[:upper:]' '[:lower:]') ARCH=$(uname -m) case "$ARCH" in x86_64|amd64) ARCH="amd64" ;; aarch64|arm64) ARCH="arm64" ;; *) echo "Unsupported architecture: $ARCH"; exit 1 ;; esac echo "Installing Mu for ${OS}/${ARCH}..." # Check for Go if command -v go >/dev/null 2>&1; then echo "Go found — building from source..." TMPDIR=$(mktemp -d) git clone --depth 1 https://github.com/${REPO}.git "$TMPDIR/mu" 2>/dev/null cd "$TMPDIR/mu" go build -o mu . mkdir -p "$BIN_DIR" mv mu "$BIN_DIR/mu" rm -rf "$TMPDIR" else # Download prebuilt binary from GitHub releases echo "Downloading prebuilt binary..." LATEST=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | head -1 | cut -d'"' -f4) if [ -z "$LATEST" ]; then echo "No releases found. Install Go and run: go install github.com/${REPO}@latest" exit 1 fi URL="https://github.com/${REPO}/releases/download/${LATEST}/mu-${OS}-${ARCH}" mkdir -p "$BIN_DIR" # Say what went wrong. A release can exist and still have no binary attached # to it — v1.5.0 did, because the cross-compile step failed before the upload # ran — and with -s and set -e the only thing on screen was "Downloading # prebuilt binary..." followed by nothing at all. The person then has a # working internet connection, a real release, and no idea why they have no # mu. Every branch here now ends in a sentence and a way forward. if ! curl -fsSL "$URL" -o "$BIN_DIR/mu"; then rm -f "$BIN_DIR/mu" echo "" echo "No ${OS}/${ARCH} binary in ${LATEST}." echo " ${URL}" echo "" echo "Install Go 1.26+ and run: go install github.com/${REPO}@latest" echo "Or report it: https://github.com/${REPO}/issues" exit 1 fi chmod +x "$BIN_DIR/mu" fi # Create data directory mkdir -p "$INSTALL_DIR" # Add to PATH if needed case ":$PATH:" in *":$BIN_DIR:"*) ;; *) SHELL_NAME=$(basename "$SHELL") case "$SHELL_NAME" in zsh) RC="$HOME/.zshrc" ;; bash) RC="$HOME/.bashrc" ;; *) RC="" ;; esac if [ -n "$RC" ] && ! grep -q "$BIN_DIR" "$RC" 2>/dev/null; then echo "export PATH=\"$BIN_DIR:\$PATH\"" >> "$RC" echo "Added $BIN_DIR to PATH in $RC" fi export PATH="$BIN_DIR:$PATH" ;; esac echo "" echo "✓ Mu installed to $BIN_DIR/mu" echo "" echo "Quick start:" echo "" echo " mu --serve" echo " # then open http://localhost:8080 — Mu walks you through" echo " # creating an admin account and picking an AI provider." echo "" echo " # Prefer the terminal? Configure the provider first:" echo " mu setup" echo ""