diff --git a/.agents/scripts/issue-sync-helper.sh b/.agents/scripts/issue-sync-helper.sh index 5052be77db..74cfdcda7d 100755 --- a/.agents/scripts/issue-sync-helper.sh +++ b/.agents/scripts/issue-sync-helper.sh @@ -18,7 +18,13 @@ set -euo pipefail -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" || exit +# Defensive PATH export — ensures coreutils (sed, grep, awk, jq, gh) are available +# in headless/MCP environments where PATH may be minimal. +export PATH="/usr/local/bin:/usr/bin:/bin:${PATH:-}" + +# Use pure-bash parameter expansion instead of dirname (which is an external binary +# and may not be in PATH in headless/MCP environments). See issue #2602. +SCRIPT_DIR="$(cd "${BASH_SOURCE[0]%/*}" && pwd)" || exit source "${SCRIPT_DIR}/shared-constants.sh" # shellcheck source=issue-sync-lib.sh source "${SCRIPT_DIR}/issue-sync-lib.sh" diff --git a/.agents/scripts/issue-sync-lib.sh b/.agents/scripts/issue-sync-lib.sh index 09fe44b292..f092e9bb8a 100755 --- a/.agents/scripts/issue-sync-lib.sh +++ b/.agents/scripts/issue-sync-lib.sh @@ -28,7 +28,9 @@ _ISSUE_SYNC_LIB_LOADED=1 # Source shared-constants.sh to make the library self-contained. # Resolves SCRIPT_DIR from BASH_SOURCE so it works when sourced from any location. if [[ -z "${SCRIPT_DIR:-}" ]]; then - SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + # Use pure-bash parameter expansion instead of dirname (external binary). + # See issue #2602 — dirname may not be in PATH in headless/MCP environments. + SCRIPT_DIR="$(cd "${BASH_SOURCE[0]%/*}" && pwd)" fi source "${SCRIPT_DIR}/shared-constants.sh"