From ed4a4d26bc8d4c160db8482fbe81086219150b95 Mon Sep 17 00:00:00 2001 From: Ashwin Bhat Date: Mon, 24 Nov 2025 20:45:51 -0500 Subject: [PATCH] fix: use cross-platform timeout for Claude Code installation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The GNU `timeout` command is not available on macOS, which breaks the action on macOS self-hosted runners. Replace with a portable bash approach using background process management. Also extracts the version into a CLAUDE_CODE_VERSION variable for easier maintenance. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- action.yml | 14 ++++++++++++-- base-action/action.yml | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index efc4bc50..5acbb41a 100644 --- a/action.yml +++ b/action.yml @@ -195,13 +195,23 @@ runs: # Install Claude Code if no custom executable is provided if [ -z "${{ inputs.path_to_claude_code_executable }}" ]; then - echo "Installing Claude Code..." + CLAUDE_CODE_VERSION="2.0.50" + echo "Installing Claude Code v${CLAUDE_CODE_VERSION}..." for attempt in 1 2 3; do echo "Installation attempt $attempt..." - if timeout 120 bash -c 'curl -fsSL https://claude.ai/install.sh | bash -s -- 2.0.50'; then + # Cross-platform timeout (GNU timeout not available on macOS) + (curl -fsSL https://claude.ai/install.sh | bash -s -- "$CLAUDE_CODE_VERSION") & + install_pid=$! + ( sleep 120; kill $install_pid 2>/dev/null ) & + timeout_pid=$! + if wait $install_pid 2>/dev/null; then + kill $timeout_pid 2>/dev/null + wait $timeout_pid 2>/dev/null echo "Claude Code installed successfully" break fi + kill $timeout_pid 2>/dev/null + wait $timeout_pid 2>/dev/null if [ $attempt -eq 3 ]; then echo "Failed to install Claude Code after 3 attempts" exit 1 diff --git a/base-action/action.yml b/base-action/action.yml index 7ebfb647..9ace0b41 100644 --- a/base-action/action.yml +++ b/base-action/action.yml @@ -117,13 +117,23 @@ runs: shell: bash run: | if [ -z "${{ inputs.path_to_claude_code_executable }}" ]; then - echo "Installing Claude Code..." + CLAUDE_CODE_VERSION="2.0.50" + echo "Installing Claude Code v${CLAUDE_CODE_VERSION}..." for attempt in 1 2 3; do echo "Installation attempt $attempt..." - if timeout 120 bash -c 'curl -fsSL https://claude.ai/install.sh | bash -s -- 2.0.50'; then + # Cross-platform timeout (GNU timeout not available on macOS) + (curl -fsSL https://claude.ai/install.sh | bash -s -- "$CLAUDE_CODE_VERSION") & + install_pid=$! + ( sleep 120; kill $install_pid 2>/dev/null ) & + timeout_pid=$! + if wait $install_pid 2>/dev/null; then + kill $timeout_pid 2>/dev/null + wait $timeout_pid 2>/dev/null echo "Claude Code installed successfully" break fi + kill $timeout_pid 2>/dev/null + wait $timeout_pid 2>/dev/null if [ $attempt -eq 3 ]; then echo "Failed to install Claude Code after 3 attempts" exit 1