fix(installer): fail fast on missing Homebrew Node

This commit is contained in:
Peter Steinberger
2026-04-26 06:32:55 +01:00
parent 257e767e5b
commit 33b6962273
3 changed files with 109 additions and 7 deletions

View File

@@ -1353,13 +1353,16 @@ ensure_macos_default_node_active() {
active_path="$(command -v node 2>/dev/null || echo "not found")"
active_version="$(node -v 2>/dev/null || echo "missing")"
ui_error "Node.js v${NODE_DEFAULT_MAJOR} was installed but this shell is using ${active_version} (${active_path})"
if [[ -n "$brew_node_prefix" ]]; then
echo "Add this to your shell profile and restart shell:"
echo " export PATH=\"${brew_node_prefix}/bin:\$PATH\""
else
echo "Ensure Homebrew node@${NODE_DEFAULT_MAJOR} is first on PATH, then rerun installer."
if [[ -z "$brew_node_prefix" || ! -x "${brew_node_prefix}/bin/node" ]]; then
ui_error "Homebrew node@${NODE_DEFAULT_MAJOR} is not installed on disk"
echo "The previous 'brew install' step appears to have failed."
echo "Re-run 'brew install node@${NODE_DEFAULT_MAJOR}' directly or rerun the installer with --verbose to see the underlying error."
return 1
fi
ui_error "Node.js v${NODE_DEFAULT_MAJOR} was installed but this shell is using ${active_version} (${active_path})"
echo "Add this to your shell profile and restart shell:"
echo " export PATH=\"${brew_node_prefix}/bin:\$PATH\""
return 1
}
@@ -1423,7 +1426,10 @@ check_node() {
install_node() {
if [[ "$OS" == "macos" ]]; then
ui_info "Installing Node.js via Homebrew"
run_quiet_step "Installing node@${NODE_DEFAULT_MAJOR}" brew install "node@${NODE_DEFAULT_MAJOR}"
if ! run_quiet_step "Installing node@${NODE_DEFAULT_MAJOR}" brew install "node@${NODE_DEFAULT_MAJOR}"; then
echo "Re-run with --verbose or run 'brew install node@${NODE_DEFAULT_MAJOR}' directly, then rerun the installer."
exit 1
fi
brew link "node@${NODE_DEFAULT_MAJOR}" --overwrite --force 2>/dev/null || true
if ! ensure_macos_default_node_active; then
exit 1