From 9df2996a5d405eb305ae702c418276f634d43060 Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Wed, 18 Mar 2026 11:17:31 +0200 Subject: [PATCH] fix: harden error handling and shell-agnostic mise activation - Guard x-path call to prevent PATH clobber when missing - Make husky init.sh use shell-agnostic mise activate --shims - Add fail-fast to Tier 2 install steps in dfm install all - Check brew update exit status before reporting success - Always run mise install during reset_nvim (handles bootstrap) - Use double-bracket conditional in cleanup script --- config/exports | 6 ++++-- config/husky/init.sh | 2 +- local/bin/dfm | 15 +++++++++------ scripts/cleanup-old-version-managers.sh | 2 +- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/config/exports b/config/exports index 92f533e..014070f 100755 --- a/config/exports +++ b/config/exports @@ -20,8 +20,10 @@ # Bootstrap: ensure local/bin is on PATH so x-path is available PATH="$DOTFILES/local/bin:$PATH" -# Use x-path to deduplicate PATH entries -PATH="$(x-path prepend "$XDG_BIN_HOME" "$DOTFILES/local/bin" "/opt/homebrew/bin" "/usr/local/bin")" +# Use x-path to deduplicate PATH entries (only if x-path is available) +if command -v x-path &> /dev/null; then + PATH="$(x-path prepend "$XDG_BIN_HOME" "$DOTFILES/local/bin" "/opt/homebrew/bin" "/usr/local/bin")" +fi export PATH if ! command -v msg &> /dev/null; then diff --git a/config/husky/init.sh b/config/husky/init.sh index caa03ba..9a333d9 100755 --- a/config/husky/init.sh +++ b/config/husky/init.sh @@ -1,2 +1,2 @@ #!/usr/bin/env bash -eval "$(mise activate bash --shims)" +eval "$(mise activate --shims)" diff --git a/local/bin/dfm b/local/bin/dfm index 1234b59..e6421fc 100755 --- a/local/bin/dfm +++ b/local/bin/dfm @@ -105,9 +105,9 @@ section_install() $0 install fonts # Tier 2: Runtimes and CLI tools via mise, then remaining installers - $0 install mise - $0 install composer - $0 install python-libs + $0 install mise || exit 1 + $0 install composer || exit 1 + $0 install python-libs || exit 1 # Tier 3: Tool-dependent installers $0 install cheat-databases @@ -268,8 +268,11 @@ section_brew() ;; update) - brew update && brew outdated && brew upgrade && brew cleanup - msgr yay "Done!" + if brew update && brew outdated && brew upgrade && brew cleanup; then + msgr yay "Done!" + else + msgr err "brew update failed" + fi ;; updatebundle) @@ -548,7 +551,7 @@ section_dotfiles() msgr ok "Deleted old nvim files (share, state and cache + config)" ln -s "$DOTFILES/config/nvim" ~/.config/nvim msgr ok "Linked nvim and astronvim" - x-have mise && $0 install mise + $0 install mise msgr ok "Installed packages" msgr run_done "nvim reset!" ;; diff --git a/scripts/cleanup-old-version-managers.sh b/scripts/cleanup-old-version-managers.sh index 959b0ba..405c64f 100755 --- a/scripts/cleanup-old-version-managers.sh +++ b/scripts/cleanup-old-version-managers.sh @@ -5,7 +5,7 @@ set -euo pipefail # because nvim's Mason installs some of the same tool names. # # Ensure DOTFILES is set even when script is invoked directly -if [ -z "${DOTFILES:-}" ]; then +if [[ -z "${DOTFILES:-}" ]]; then DOTFILES="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" export DOTFILES fi