From 55f7990bc60ba8ba74b8e6bfb1ed7aef32bd81ef Mon Sep 17 00:00:00 2001 From: CyberSecurityUP Date: Thu, 26 Nov 2026 11:18:03 -0300 Subject: [PATCH] fix(setup): don't abort silently when a dependency install fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit setup.sh runs with set -e and pkg_install swallowed the package manager's output, so a failed apt-get install nodejs killed the installer right after "node missing — installing…" with no message. pkg_install is now best-effort and prints the tail of the package manager's error on failure. --- setup.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/setup.sh b/setup.sh index d307937..b0d1d10 100755 --- a/setup.sh +++ b/setup.sh @@ -165,15 +165,23 @@ elif command -v pacman >/dev/null 2>&1; then PKG="pacman" elif command -v apk >/dev/null 2>&1; then PKG="apk"; fi [ "$(id -u)" = "0" ] || command -v sudo >/dev/null 2>&1 && [ "$(id -u)" != "0" ] && SUDO="sudo" -pkg_install() { # pkg_install +pkg_install() { # pkg_install — best-effort: never aborts the installer (set -e) [ -n "$PKG" ] || { warn "no supported package manager — install manually: $*"; return 0; } + local log; log="$(mktemp 2>/dev/null || echo /tmp/neurosploit-pkg.log)" + local rc=0 case "$PKG" in - apt) $SUDO apt-get update -qq >/dev/null 2>&1; $SUDO apt-get install -y "$@" >/dev/null 2>&1 ;; - brew) brew install "$@" >/dev/null 2>&1 ;; - dnf) $SUDO dnf install -y "$@" >/dev/null 2>&1 ;; - pacman) $SUDO pacman -Sy --noconfirm "$@" >/dev/null 2>&1 ;; - apk) $SUDO apk add "$@" >/dev/null 2>&1 ;; + apt) { $SUDO apt-get update -qq && DEBIAN_FRONTEND=noninteractive $SUDO apt-get install -y "$@"; } >"$log" 2>&1 || rc=$? ;; + brew) brew install "$@" >"$log" 2>&1 || rc=$? ;; + dnf) $SUDO dnf install -y "$@" >"$log" 2>&1 || rc=$? ;; + pacman) $SUDO pacman -Sy --noconfirm "$@" >"$log" 2>&1 || rc=$? ;; + apk) $SUDO apk add "$@" >"$log" 2>&1 || rc=$? ;; esac + if [ "$rc" != "0" ]; then + warn "$PKG failed installing: $* (exit $rc) — last lines:" + tail -n 5 "$log" 2>/dev/null | sed 's/^/ /' + fi + rm -f "$log" + return 0 } # Map a required command to its package name on the detected manager.