From 4f25d07beb3a38542963f5dbaba031d4bdf7fd0a Mon Sep 17 00:00:00 2001 From: aitbc Date: Tue, 26 May 2026 10:11:06 +0200 Subject: [PATCH] feat: add comprehensive error handling for venv and poetry steps - Add error handling for venv activation (both new and existing) - Add error handling for pip upgrade (continues if fails) - Add error handling for Poetry installation - Add error handling for poetry install command - Provide manual recovery instructions for each failure point - Prevents script from failing completely on venv/poetry issues - Improves hermes agent setup reliability --- scripts/setup.sh | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/scripts/setup.sh b/scripts/setup.sh index 7ead5170..7674ed65 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -409,11 +409,27 @@ setup_venvs() { fi fi - source venv/bin/activate - pip install --upgrade pip + # Activate venv with error handling + if ! source venv/bin/activate; then + warning "Failed to activate virtual environment" + warning "Virtual environment may be corrupted" + warning "Manual fix: rm -rf /opt/aitbc/venv && python3 -m venv /opt/aitbc/venv" + return 0 + fi + + # Upgrade pip with error handling + if ! pip install --upgrade pip; then + warning "Failed to upgrade pip in virtual environment" + warning "Continuing with existing pip version" + fi else log "Central virtual environment already exists, activating..." - source /opt/aitbc/venv/bin/activate + if ! source /opt/aitbc/venv/bin/activate; then + warning "Failed to activate existing virtual environment" + warning "Virtual environment may be corrupted" + warning "Manual fix: rm -rf /opt/aitbc/venv && python3 -m venv /opt/aitbc/venv" + return 0 + fi fi # Install all dependencies using Poetry @@ -421,8 +437,19 @@ setup_venvs() { # Install using Poetry (source of truth is pyproject.toml) if [ -f "/opt/aitbc/pyproject.toml" ]; then - pip install poetry - poetry install + log "Installing Poetry..." + if ! pip install poetry; then + warning "Failed to install Poetry" + warning "Skipping Poetry-based dependency installation" + warning "Dependencies may need to be installed manually" + else + log "Running poetry install..." + if ! poetry install; then + warning "Poetry install failed" + warning "Dependencies may need to be installed manually" + warning "Manual install: cd /opt/aitbc && source venv/bin/activate && pip install -e cli/ apps/blockchain-node/" + fi + fi else warning "pyproject.toml not found, skipping Poetry installation" fi