Skip to content

t2602: Fix issue-sync-helper.sh dirname failure in headless pulse#2604

Closed
marcusquinn wants to merge 1 commit intomainfrom
bugfix/issue-sync-dirname-fix
Closed

t2602: Fix issue-sync-helper.sh dirname failure in headless pulse#2604
marcusquinn wants to merge 1 commit intomainfrom
bugfix/issue-sync-dirname-fix

Conversation

@marcusquinn
Copy link
Copy Markdown
Owner

@marcusquinn marcusquinn commented Feb 28, 2026

Summary

  • Replace dirname (external binary) with pure-bash ${BASH_SOURCE[0]%/*} parameter expansion in issue-sync-helper.sh and issue-sync-lib.sh — fixes "dirname: command not found" in headless/MCP environments
  • Add defensive PATH export at script entry to ensure coreutils (sed, grep, awk, jq, gh) are available in restricted environments
  • Both changes are backward-compatible — ${var%/*} is POSIX and works on bash 3.2+

Root Cause

In headless pulse sessions (Claude Code MCP shell), /usr/bin and /usr/local/bin may not be in PATH. dirname is a coreutils binary, not a shell builtin, so $(dirname "${BASH_SOURCE[0]}") fails with "command not found". This caused TODO sync to silently fail on every pulse cycle across all 6 repos.

Testing

  • bash -n syntax check: pass
  • shellcheck: no new warnings (only pre-existing SC1091 info)
  • Functional test: issue-sync-helper.sh help runs successfully
  • Verified ${BASH_SOURCE[0]%/*} produces identical output to dirname

Closes #2602

Summary by CodeRabbit

  • Chores
    • Improved reliability of agent scripts when running in minimal-environment configurations by reducing external tool dependencies and optimizing initialization logic.

…2602)

issue-sync-helper.sh fails in headless pulse sessions because dirname
(a coreutils binary) is not in PATH in restricted MCP environments.

Replace $(dirname "${BASH_SOURCE[0]}") with ${BASH_SOURCE[0]%/*}
(POSIX parameter expansion — no external binary required) in both
issue-sync-helper.sh and issue-sync-lib.sh.

Also add defensive PATH export at script entry to ensure sed, grep,
awk, jq, and gh are available in headless environments.

Closes #2602
@gemini-code-assist
Copy link
Copy Markdown

Warning

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

@github-actions github-actions bot added the bug Auto-created from TODO.md tag label Feb 28, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 28, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 00b4fb9 and b646cab.

📒 Files selected for processing (2)
  • .agents/scripts/issue-sync-helper.sh
  • .agents/scripts/issue-sync-lib.sh

Walkthrough

The PR fixes headless MCP environment failures by replacing the external dirname command with pure-bash parameter expansion (${BASH_SOURCE[0]%/*}) across two initialization scripts, and adds a defensive PATH export to ensure coreutils availability in restricted shell environments.

Changes

Cohort / File(s) Summary
Headless Environment Fixes
.agents/scripts/issue-sync-helper.sh
Added defensive PATH export (/usr/bin:/usr/local/bin) at script start; replaced $(dirname "$0") with pure-bash expansion ${BASH_SOURCE[0]%/*} to eliminate external binary dependency.
Shared Library Initialization
.agents/scripts/issue-sync-lib.sh
Replaced $(dirname "${BASH_SOURCE[0]}") with pure-bash parameter expansion ${BASH_SOURCE[0]%/*} when computing SCRIPT_DIR to avoid dirname reliance in restricted environments.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

🔧 When dirname goes missing from the shell,
Pure bash expansion works oh so well,
No /usr/bin needed, no fuss to unfold,
Parameter expansion—efficient and bold! 🚀

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix/issue-sync-dirname-fix

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.

@marcusquinn
Copy link
Copy Markdown
Owner Author

Duplicate of #2603 — both PRs fix the same dirname issue in issue-sync-helper.sh for issue #2602. PR #2603 was created first and includes an additional edge case fix for find_project_root() at filesystem root. Closing this PR in favour of #2603.

Supervisor pulse action: 2026-02-28T05:49 UTC

@marcusquinn
Copy link
Copy Markdown
Owner Author

Closing as duplicate of #2603 — same fix, #2603 is more thorough and was created first.

@github-actions
Copy link
Copy Markdown
Contributor

🔍 Code Quality Report

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

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

�[0;34m[INFO]�[0m Recent monitoring activity:
Sat Feb 28 05:50:05 UTC 2026: Code review monitoring started
Sat Feb 28 05:50:06 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 106

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 106
  • VULNERABILITIES: 0

Generated on: Sat Feb 28 05:50:08 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link
Copy Markdown

@marcusquinn marcusquinn deleted the bugfix/issue-sync-dirname-fix branch March 3, 2026 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Auto-created from TODO.md tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: issue-sync-helper.sh fails in headless pulse — dirname not found

1 participant