From 01eda7cd7fb77264fea6e6b170fe473bf6effe4f Mon Sep 17 00:00:00 2001 From: rain Date: Sun, 21 Jun 2026 19:41:50 -0400 Subject: [PATCH] Drop id -u root check from run_once scripts chezmoi runs run_once_* scripts as the invoking user (uid != 0). The earlier check [[ $(id -u) -ne 0 ]] && die ... killed the script immediately when invoked via 'chezmoi apply' or 'chezmoi init --apply' from a normal user session. The scripts use sudo internally for package operations (pacman/apt), so elevation happens correctly. The id -u check was wrong: it belongs in a script that's *meant* to be invoked as root directly, not in a chezmoi-managed script. --- run_once_00-install-bootstrap-tools.sh.tmpl | 4 +++- run_once_10-add-chaotic-aur.sh.tmpl | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/run_once_00-install-bootstrap-tools.sh.tmpl b/run_once_00-install-bootstrap-tools.sh.tmpl index ac5aae0..3d7f0fa 100755 --- a/run_once_00-install-bootstrap-tools.sh.tmpl +++ b/run_once_00-install-bootstrap-tools.sh.tmpl @@ -9,7 +9,9 @@ set -euo pipefail log() { printf '\033[1;34m[bootstrap]\033[0m %s\n' "$*"; } die() { printf '\033[1;31m[bootstrap ERROR]\033[0m %s\n' "$*" >&2; exit 1; } -[[ "$(id -u)" -ne 0 ]] && die "must run as root or via sudo" +# This script runs as the invoking user via `chezmoi apply`/`init`. It uses +# sudo for system package installs. If sudo isn't passwordless, the user +# will be prompted once per sudo invocation. {{ if eq .os_family "arch" -}} log "pacman-sync" diff --git a/run_once_10-add-chaotic-aur.sh.tmpl b/run_once_10-add-chaotic-aur.sh.tmpl index 1acd0dc..ab8417e 100755 --- a/run_once_10-add-chaotic-aur.sh.tmpl +++ b/run_once_10-add-chaotic-aur.sh.tmpl @@ -14,7 +14,8 @@ set -euo pipefail log() { printf '\033[1;34m[chaotic]\033[0m %s\n' "$*"; } die() { printf '\033[1;31m[chaotic ERROR]\033[0m %s\n' "$*" >&2; exit 1; } -[[ "$(id -u)" -ne 0 ]] && die "must run as root or via sudo" +# This script runs as the invoking user; sudo handles elevation for pacman +# and pacman-key operations below. if command -v paru >/dev/null 2>&1; then log "paru already installed — skipping chaotic setup"