From e3242f50ab72441d10d6601441185ff759feaa06 Mon Sep 17 00:00:00 2001 From: Alberto De Bortoli Date: Sun, 26 Jul 2026 12:25:08 +0100 Subject: [PATCH] Fix sudo check for non-existent install directories When the install directory doesn't exist yet, walk up to the first existing ancestor to check writability, rather than checking the non-existent directory itself (which always returns false and incorrectly triggers sudo). --- install.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 1e1d0c3..1a5b7ef 100755 --- a/install.sh +++ b/install.sh @@ -211,8 +211,13 @@ echo "✅ Extraction completed" sudo_if_install_dir_not_writeable() { local command="$1" local exit_code - if [ -w "$INSTALL_DIR" ]; then - # Directory is writable, run without sudo + local check_dir="$INSTALL_DIR" + # Walk up to find the first existing ancestor to check writability + while [ -n "$check_dir" ] && [ "$check_dir" != "/" ] && [ ! -e "$check_dir" ]; do + check_dir="$(dirname "$check_dir")" + done + if [ -w "$check_dir" ]; then + # Directory (or its ancestor) is writable, run without sudo sh -c "$command" else # Directory requires elevated privileges