Skip to content

Fix directory creation issue in Claude settings generation#495

Merged
pelikhan merged 2 commits intomainfrom
copilot/investigate-action-run-failure
Sep 6, 2025
Merged

Fix directory creation issue in Claude settings generation#495
pelikhan merged 2 commits intomainfrom
copilot/investigate-action-run-failure

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 6, 2025

Problem

The agent-cook workflow was failing at the "Generate Claude Settings" step with the error:

.claude/settings.json: No such file or directory

This occurred because the Claude settings generation step attempted to create .claude/settings.json directly without first ensuring the .claude directory exists.

Root Cause

In pkg/workflow/claude_settings.go, the GenerateSettingsWorkflowStep() function generated a shell command that tried to create the settings file immediately:

cat > .claude/settings.json << 'EOF'
{
  "hooks": { ... }
}
EOF

However, in a fresh GitHub Actions checkout, the .claude directory doesn't exist, causing the file creation to fail.

Solution

Added a directory creation command before the file creation:

runContent := fmt.Sprintf(`mkdir -p .claude
cat > .claude/settings.json << 'EOF'
%s
EOF`, settingsJSON)

The mkdir -p flag ensures:

  • The directory is created if it doesn't exist
  • No error occurs if the directory already exists
  • Parent directories are created if needed

Testing

  • Added test coverage to verify the directory creation command is generated before file creation
  • All existing tests continue to pass
  • Successfully compiled all workflows including the previously failing agent-cook workflow
  • Verified the generated workflow now includes the proper directory creation step

Impact

This is a minimal fix that resolves the immediate workflow failure while maintaining backward compatibility. Any workflow using the Claude engine with network permissions will now work correctly in fresh repository checkouts.

Fixes the workflow failure reported in https://github.com/githubnext/gh-aw/actions/runs/17518643684/job/49759549903

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.contoso.com
    • Triggering command: /tmp/go-build689472753/b278/cli.test -test.testlogfile=/tmp/go-build689472753/b278/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true (dns block)
    • Triggering command: /tmp/go-build2673252272/b278/cli.test -test.testlogfile=/tmp/go-build2673252272/b278/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

- Add mkdir -p .claude command before creating settings.json
- Update test to verify directory creation happens before file creation
- Fix resolves "No such file or directory" error in agent-cook workflow
- All tests pass and workflows compile successfully

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate why this action run failed: https://github.com/githubnext/gh-aw/actions/runs/17518643684/job/49759549903 Fix directory creation issue in Claude settings generation Sep 6, 2025
Copilot AI requested a review from pelikhan September 6, 2025 19:44
@pelikhan pelikhan marked this pull request as ready for review September 6, 2025 19:46
@pelikhan pelikhan merged commit a5f0fc3 into main Sep 6, 2025
22 checks passed
@pelikhan pelikhan deleted the copilot/investigate-action-run-failure branch September 6, 2025 19:51
Copilot AI added a commit that referenced this pull request Mar 26, 2026
pelikhan added a commit that referenced this pull request Mar 26, 2026
* Initial plan

* fix: remove unused 'devices' import in docs/test-mobile.mjs (CodeQL #495)

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/1a2a2e18-88e1-44c2-997e-1f719dc3c6f5

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants