From 75ad9547913dff4e8782333cc734dc31b779fee9 Mon Sep 17 00:00:00 2001 From: Vito Castellano Date: Mon, 29 Dec 2025 23:14:51 +0100 Subject: [PATCH] fix(install): use sudo for apt-get when not running as root GitHub Actions runners are not root, so apt-get needs sudo. Detect if running as non-root and use sudo when available. --- install.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index 3e76e4e..dbd27f1 100755 --- a/install.sh +++ b/install.sh @@ -88,16 +88,22 @@ command_exists() { install_linux_deps() { info "Installing required dependencies..." + # Use sudo if available and not root + SUDO="" + if [ "$(id -u)" -ne 0 ] && command_exists sudo; then + SUDO="sudo" + fi + if command_exists apt-get; then # Debian/Ubuntu - apt-get update -qq - apt-get install -y -qq build-essential procps curl file git > /dev/null + $SUDO apt-get update -qq + $SUDO apt-get install -y -qq build-essential procps curl file git > /dev/null elif command_exists dnf; then # Fedora/RHEL - dnf install -y -q procps-ng curl file git gcc make > /dev/null + $SUDO dnf install -y -q procps-ng curl file git gcc make > /dev/null elif command_exists pacman; then # Arch - pacman -Sy --noconfirm --quiet base-devel procps-ng curl file git > /dev/null + $SUDO pacman -Sy --noconfirm --quiet base-devel procps-ng curl file git > /dev/null else warn "Could not detect package manager. Please install: git, curl, build-essential" fi