Skip to content

fix: setup.sh set-e resilience, template path, npm/sudo, and venv recovery#693

Merged
marcusquinn merged 1 commit intomainfrom
bugfix/setup-sete-resilience
Feb 9, 2026
Merged

fix: setup.sh set-e resilience, template path, npm/sudo, and venv recovery#693
marcusquinn merged 1 commit intomainfrom
bugfix/setup-sete-resilience

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Feb 9, 2026

Summary

Fixes multiple set -e crashes in setup.sh that prevent the installer from completing on fresh Linux systems (tested on OrbStack Ubuntu ARM64).

Changes

Template path mismatch (Fix A)

  • Renamed templates/home/.agent/ to templates/home/.agents/ to match the path referenced in deploy-templates.sh line 171

Dead-code $? patterns (Fixes B, +3 more)

With set -euo pipefail, any non-zero command exit kills the script before if [[ $? -eq 0 ]] is reached. Converted all instances to if command; then pattern:

  • deploy_ai_templates()bash templates/deploy-templates.sh
  • bootstrap_repo()git pull --ff-only and git clone
  • deploy_aidevops_agents()rsync/tar fallback

Missing npm when Node.js exists (Fix C)

  • Distro nodejs package (e.g., Ubuntu apt) may not include npm
  • setup_nodejs() now checks for npm when Node.js is already installed and installs it if missing

DSPy venv resilience (Fix D)

  • Detects corrupted venv (directory exists but activate script missing)
  • Recreates venv instead of crashing on source .../activate
  • Guards source with file existence check

OpenCode CLI non-interactive mode (Fix E)

  • Guards read -r -p prompt with NON_INTERACTIVE check
  • Falls back to "Y" (install) in non-interactive mode

npm global install sudo on Linux (Fix F)

  • npm global installs need sudo on Linux when prefix directory isn't writable
  • Detects this condition and prepends sudo automatically
  • bun global installs don't need sudo (writes to ~/.bun/bin)

Testing

  • ./setup.sh --non-interactive completes with exit code 0 on OrbStack Ubuntu ARM64
  • ShellCheck passes (only pre-existing SC2155 warnings)
  • bash -n setup.sh syntax check passes

Summary by CodeRabbit

  • Chores
    • Improved setup and deployment script reliability with enhanced error handling and validation checks
    • Added better support for non-interactive automated environments and CI pipelines
    • Strengthened dependency detection and initialization for language runtimes and CLI tools
    • Enhanced fallback behavior when tools or environments are missing or corrupted

…overy

- Rename templates/home/.agent/ to .agents/ (matches deploy-templates.sh reference)
- Fix deploy_ai_templates dead-code $? pattern (set -e kills before check)
- Fix git pull/clone dead-code $? patterns in bootstrap_repo
- Fix deploy_aidevops_agents rsync/tar dead-code $? pattern
- Add npm install when Node.js exists without npm (distro packages)
- Fix DSPy venv: detect corrupted venv, recreate if activate missing
- Guard OpenCode CLI read prompt for non-interactive mode
- Use sudo for npm global install on Linux when prefix not writable
@gemini-code-assist
Copy link

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 9, 2026

Walkthrough

The setup.sh script refactors control flow across multiple functions to replace exit-status checks with direct negated command invocations. Enhanced error handling strengthens activation checks for Python venv, Node.js, and CLI tools. Non-interactive mode support expanded with safe defaults, deploy-status flags introduced, and package-manager-aware installation logic reinforced.

Changes

Cohort / File(s) Summary
Error Handling & Exit-Status Checks
setup.sh (bootstrap_repo, deploy_ai_templates, deploy_aidevops_agents functions)
Replaced explicit $? checks with negated command invocations (if ! command) and introduced deploy_ok flag for deployment status tracking, improving error detection resilience.
Environment & Activation Guards
setup.sh (setup_python_env function)
Enhanced venv creation logic to detect and recover from corrupted environments; added guard checking for activate script presence before proceeding with fallback warnings.
Package Manager & CLI Installation
setup.sh (setup_nodejs, setup_opencode_cli, setup_aidevops_cli functions)
Implemented package-manager-aware install logic with sudo handling; added npm fallback when missing post-Node.js install; improved manual installation guidance with visible commands.
Non-Interactive Mode Support
setup.sh (setup_opencode_cli, setup_aidevops_cli functions)
Converted interactive prompts to default-yes safe patterns; gated conditional prompts behind NON_INTERACTIVE checks; enhanced CI/automation compatibility.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🔧 Where exit codes once led the way,
Negated commands now save the day,
Guards and flags stand firm and true,
Non-interactive flows run right on through,
Shell scripts shine with zero debt—DevOps automation is set! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title precisely summarizes all major fixes: set-e resilience, template path correction, npm/sudo handling, and venv recovery—matching the detailed PR objectives.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix/setup-sete-resilience

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

github-actions bot commented Feb 9, 2026

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 44 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Mon Feb 9 00:06:01 UTC 2026: Code review monitoring started
Mon Feb 9 00:06:01 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 44

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 44
  • VULNERABILITIES: 0

Generated on: Mon Feb 9 00:06:04 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 9, 2026

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
setup.sh (1)

3106-3131: ⚠️ Potential issue | 🟡 Minor

Solid venv recovery logic — minor inconsistency with python binary.

The corrupted-venv detection (directory exists, activate missing → remove and recreate) is a good fix. The source guard on line 3126 prevents the set -e crash that the PR objectives describe.

One minor inconsistency: line 3113 uses bare python3 for venv creation, but find_python3() was already called on line 3089 and resolved to $python3_bin (which may point to /opt/homebrew/bin/python3 or a pyenv shim). On systems where python3 in $PATH differs from the resolved $python3_bin, the venv could be created with the wrong interpreter.

Suggested fix
-        if python3 -m venv python-env/dspy-env; then
+        if "$python3_bin" -m venv python-env/dspy-env; then

@marcusquinn marcusquinn merged commit 2b9d5ae into main Feb 9, 2026
11 checks passed
@marcusquinn marcusquinn deleted the bugfix/setup-sete-resilience branch February 9, 2026 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant