Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ runs:
echo "Installing Claude Code v${CLAUDE_CODE_VERSION}..."
for attempt in 1 2 3; do
echo "Installation attempt $attempt..."

# Clean up stale lock files before retry
rm -rf ~/.claude/.locks 2>/dev/null || true
Copy link
Contributor

Choose a reason for hiding this comment

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

Performance & Logic Optimization: Consider moving the lock cleanup to only execute after a failed attempt rather than before every attempt (including the first). This would be more logically correct since locks only exist after a timeout/failure.

Suggested change
rm -rf ~/.claude/.locks 2>/dev/null || true
if command -v timeout &> /dev/null; then
timeout 120 bash -c "curl -fsSL https://claude.ai/install.sh | bash -s -- $CLAUDE_CODE_VERSION" && break
else
curl -fsSL https://claude.ai/install.sh | bash -s -- "$CLAUDE_CODE_VERSION" && break
fi
if [ $attempt -eq 3 ]; then
echo "Failed to install Claude Code after 3 attempts"
exit 1
fi
# Clean up stale lock files after failure, before retry
echo "Installation failed, cleaning up stale locks before retry..."
rm -rf ~/.claude/.locks 2>/dev/null || true


if command -v timeout &> /dev/null; then
timeout 120 bash -c "curl -fsSL https://claude.ai/install.sh | bash -s -- $CLAUDE_CODE_VERSION" && break
else
Expand All @@ -214,8 +218,15 @@ runs:
echo "Installation failed, retrying..."
sleep 5
done
echo "Claude Code installed successfully"

# Add to PATH and validate installation
Copy link
Contributor

Choose a reason for hiding this comment

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

Documentation: The comment "Add to PATH and validate installation" is slightly misleading since the PATH setup already existed before this PR. Consider updating to better reflect that this is primarily adding validation:

Suggested change
# Add to PATH and validate installation
# Ensure PATH is updated and validate claude binary is accessible

echo "$HOME/.local/bin" >> "$GITHUB_PATH"
export PATH="$HOME/.local/bin:$PATH"
if ! command -v claude &> /dev/null; then
echo "Installation failed: claude binary not found in PATH"
exit 1
fi
Comment on lines +225 to +228
Copy link
Contributor

Choose a reason for hiding this comment

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

Enhancement: Consider adding debugging context to help diagnose installation failures in CI logs:

Suggested change
if ! command -v claude &> /dev/null; then
echo "Installation failed: claude binary not found in PATH"
exit 1
fi
if ! command -v claude &> /dev/null; then
echo "Installation failed: claude binary not found in PATH"
echo "Current PATH: $PATH"
echo "Contents of ~/.local/bin:"
ls -la ~/.local/bin/ 2>&1 || echo "Directory does not exist"
exit 1
fi

echo "Claude Code installed successfully"
else
echo "Using custom Claude Code executable: $PATH_TO_CLAUDE_CODE_EXECUTABLE"
# Add the directory containing the custom executable to PATH
Expand Down
12 changes: 12 additions & 0 deletions base-action/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ runs:
echo "Installing Claude Code v${CLAUDE_CODE_VERSION}..."
for attempt in 1 2 3; do
echo "Installation attempt $attempt..."

# Clean up stale lock files before retry
rm -rf ~/.claude/.locks 2>/dev/null || true
Copy link
Contributor

Choose a reason for hiding this comment

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

Performance & Logic Optimization: Same as in action.yml - consider moving lock cleanup to only execute after failures, not before the first attempt.

Suggested change
rm -rf ~/.claude/.locks 2>/dev/null || true
if command -v timeout &> /dev/null; then
timeout 120 bash -c "curl -fsSL https://claude.ai/install.sh | bash -s -- $CLAUDE_CODE_VERSION" && break
else
curl -fsSL https://claude.ai/install.sh | bash -s -- "$CLAUDE_CODE_VERSION" && break
fi
if [ $attempt -eq 3 ]; then
echo "Failed to install Claude Code after 3 attempts"
exit 1
fi
# Clean up stale lock files after failure, before retry
echo "Installation failed, cleaning up stale locks before retry..."
rm -rf ~/.claude/.locks 2>/dev/null || true

Copy link

Choose a reason for hiding this comment

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

The lock cleanup path may need adjustment. Community workarounds in issue #709 report success with ~/.local/state/claude/locks rather than ~/.claude/.locks.

From the comments:

  • rm -rf ~/.local/state/claude/locks has 52+ positive reactions
  • Confirmed working on Ubuntu, macOS, Fedora, and Windows (C:\Users{user}.local\state\claude)

Consider cleaning both paths to cover different Claude Code versions:

rm -rf ~/.local/state/claude/locks 2>/dev/null || true
rm -rf ~/.claude/.locks 2>/dev/null || true


if command -v timeout &> /dev/null; then
timeout 120 bash -c "curl -fsSL https://claude.ai/install.sh | bash -s -- $CLAUDE_CODE_VERSION" && break
else
Expand All @@ -140,6 +144,14 @@ runs:
echo "Installation failed, retrying..."
sleep 5
done

# Add to PATH and validate installation
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
export PATH="$HOME/.local/bin:$PATH"
if ! command -v claude &> /dev/null; then
echo "Installation failed: claude binary not found in PATH"
exit 1
fi
echo "Claude Code installed successfully"
else
echo "Using custom Claude Code executable: $PATH_TO_CLAUDE_CODE_EXECUTABLE"
Expand Down
Loading