diff --git a/ui/desktop/src/bin/node-setup-common.sh b/ui/desktop/src/bin/node-setup-common.sh index 97c3551d5ac0..16eee6854714 100755 --- a/ui/desktop/src/bin/node-setup-common.sh +++ b/ui/desktop/src/bin/node-setup-common.sh @@ -57,9 +57,39 @@ log "Updated PATH to include ~/.config/goose/mcp-hermit/bin." log "Checking for hermit in PATH." which hermit >> "$LOG_FILE" -# Initialize hermit -log "Initializing hermit." -hermit init >> "$LOG_FILE" +# Check if hermit environment is already initialized (only run init on first setup) +if [ ! -f bin/activate-hermit ]; then + log "Hermit environment not yet initialized. Setting up hermit." + + # Fix hermit self-update lock issues on Linux by using temp binary for init only + if [[ "$(uname -s)" == "Linux" ]]; then + log "Creating temp dir with bin subdirectory for hermit copy to avoid self-update locks." + HERMIT_TMP_DIR="/tmp/hermit_tmp_$$/bin" + mkdir -p "$HERMIT_TMP_DIR" + cp ~/.config/goose/mcp-hermit/bin/hermit "$HERMIT_TMP_DIR/hermit" + chmod +x "$HERMIT_TMP_DIR/hermit" + export PATH="$HERMIT_TMP_DIR:$PATH" + HERMIT_CLEANUP_DIR="/tmp/hermit_tmp_$$" + fi + + # Initialize hermit + log "Initializing hermit." + hermit init >> "$LOG_FILE" + + # Clean up temp dir if it was created + if [[ -n "${HERMIT_CLEANUP_DIR:-}" ]]; then + log "Cleaning up temporary hermit binary directory." + rm -rf "$HERMIT_CLEANUP_DIR" + fi +else + log "Hermit environment already initialized. Skipping init." +fi + +# Activate the environment with output redirected to log +if [[ "$(uname -s)" == "Linux" ]]; then + log "Activating hermit environment." + { . bin/activate-hermit; } >> "$LOG_FILE" 2>&1 +fi # Install Node.js using hermit log "Installing Node.js with hermit."