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