t1262: Fix symlink SCRIPT_DIR resolution for launchd agents#1977
t1262: Fix symlink SCRIPT_DIR resolution for launchd agents#1977marcusquinn merged 1 commit intomainfrom
Conversation
When supervisor-helper.sh and auto-update-helper.sh are invoked via symlinks in ~/.aidevops/bin/ (created by t1260 launchd setup), BASH_SOURCE[0] resolves to the symlink path, not the target. This causes SCRIPT_DIR to be ~/.aidevops/bin/ instead of the actual scripts directory, breaking shared-constants.sh sourcing (exit code 1). Fix: add _resolve_script_path() that follows symlink chain before determining SCRIPT_DIR. Works for both direct invocation and symlinks.
Summary of ChangesHello @marcusquinn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a critical issue where Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
WalkthroughThis PR fixes symlink resolution for Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Thu Feb 19 21:34:27 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
|
There was a problem hiding this comment.
Code Review
The pull request addresses a critical issue where scripts invoked via symlinks fail to locate shared-constants.sh. The fix introduces a robust _resolve_script_path function to correctly determine the script's real location by following symlinks. This ensures that SCRIPT_DIR is always accurate, allowing dependent scripts to be sourced correctly. The changes are well-tested and adhere to the repository's shell scripting standards.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.agents/scripts/auto-update-helper.sh (1)
29-43: Two minor gaps vssupervisor-helper.sh: missingreadonlyand silent failure path.
supervisor-helper.shmarksSCRIPT_DIRasreadonly(line 183) immediately after assignment;auto-update-helper.shdoes not. The AI summary claims it does, but the code disagrees — worth keeping consistent.|| exitis silent: when launchd invokes this script via the symlink and path resolution fails, the process exits with no stderr/log entry, making the failure invisible in~/.aidevops/logs/auto-update.log.Per coding guidelines:
.agents/scripts/*.shmust provide clear logging and feedback.✨ Proposed fix — add `readonly` and a diagnostic message on failure
-SCRIPT_DIR="$(_resolve_script_path)" || exit +SCRIPT_DIR="$(_resolve_script_path)" || { echo "[auto-update-helper] ERROR: failed to resolve script path" >&2; exit 1; } unset -f _resolve_script_path +readonly SCRIPT_DIR source "${SCRIPT_DIR}/shared-constants.sh"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.agents/scripts/auto-update-helper.sh around lines 29 - 43, The SCRIPT_DIR assignment in _resolve_script_path lacks the readonly qualifier and exits silently on failure; update the assignment to capture the result of _resolve_script_path into SCRIPT_DIR, mark SCRIPT_DIR readonly (like supervisor-helper.sh), and replace the silent "|| exit" with explicit failure logging (write a diagnostic to stderr or the auto-update.log explaining path resolution failed and include any error context) before exiting non-zero so failures are visible; refer to the _resolve_script_path function and the SCRIPT_DIR variable when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.agents/scripts/auto-update-helper.sh:
- Around line 29-43: The SCRIPT_DIR assignment in _resolve_script_path lacks the
readonly qualifier and exits silently on failure; update the assignment to
capture the result of _resolve_script_path into SCRIPT_DIR, mark SCRIPT_DIR
readonly (like supervisor-helper.sh), and replace the silent "|| exit" with
explicit failure logging (write a diagnostic to stderr or the auto-update.log
explaining path resolution failed and include any error context) before exiting
non-zero so failures are visible; refer to the _resolve_script_path function and
the SCRIPT_DIR variable when making the change.



Summary
supervisor-helper.shandauto-update-helper.shfailing when invoked via symlinks in~/.aidevops/bin/_resolve_script_path()that follows symlink chain before determiningSCRIPT_DIRcom.aidevops.aidevops-supervisor-pulseandcom.aidevops.aidevops-auto-update) were exit code 1 due toshared-constants.sh: No such file or directoryRoot Cause
The t1260 launchd setup creates symlinks in
~/.aidevops/bin/for nice display names in macOS System Settings:Both scripts use
BASH_SOURCE[0]to determineSCRIPT_DIR, but when invoked via symlink,BASH_SOURCE[0]is the symlink path (~/.aidevops/bin/), not the target. Sosource "${SCRIPT_DIR}/shared-constants.sh"looks for~/.aidevops/bin/shared-constants.shwhich doesn't exist.Fix
Added a portable symlink resolution function that follows the symlink chain:
Testing
/tmp/test-symlink-*→ both scripts show help output correctlyCloses #1976
Summary by CodeRabbit