Skip to content

Commit 75ad954

Browse files
committed
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.
1 parent 4be99a1 commit 75ad954

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

install.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,22 @@ command_exists() {
8888
install_linux_deps() {
8989
info "Installing required dependencies..."
9090

91+
# Use sudo if available and not root
92+
SUDO=""
93+
if [ "$(id -u)" -ne 0 ] && command_exists sudo; then
94+
SUDO="sudo"
95+
fi
96+
9197
if command_exists apt-get; then
9298
# Debian/Ubuntu
93-
apt-get update -qq
94-
apt-get install -y -qq build-essential procps curl file git > /dev/null
99+
$SUDO apt-get update -qq
100+
$SUDO apt-get install -y -qq build-essential procps curl file git > /dev/null
95101
elif command_exists dnf; then
96102
# Fedora/RHEL
97-
dnf install -y -q procps-ng curl file git gcc make > /dev/null
103+
$SUDO dnf install -y -q procps-ng curl file git gcc make > /dev/null
98104
elif command_exists pacman; then
99105
# Arch
100-
pacman -Sy --noconfirm --quiet base-devel procps-ng curl file git > /dev/null
106+
$SUDO pacman -Sy --noconfirm --quiet base-devel procps-ng curl file git > /dev/null
101107
else
102108
warn "Could not detect package manager. Please install: git, curl, build-essential"
103109
fi

0 commit comments

Comments
 (0)