Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

fix(sandbox): put Claude Code's real install directory on PATH

shukieshahd7bd4973543f
diff --git a/.github/workflows/windows-sandbox.yml b/.github/workflows/windows-sandbox.yml
index 49339570..484eb74f 100644
--- a/.github/workflows/windows-sandbox.yml
+++ b/.github/workflows/windows-sandbox.yml
@@ -149,7 +149,25 @@ jobs:
$installer = Join-Path $env:TEMP 'install-claude.ps1'
Invoke-WebRequest -Uri 'https://claude.ai/install.ps1' -OutFile $installer
& $installer $version
- "$env:LOCALAPPDATA\Programs\claude" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
+ if ($LASTEXITCODE -ne 0) { throw "the Claude Code installer exited $LASTEXITCODE" }
+
+ # install.ps1 puts the agent in %USERPROFILE%\.local\bin -- the same ~/.local/bin
+ # convention the Linux image uses, not a Windows-specific Programs directory.
+ $claudeBin = Join-Path $env:USERPROFILE '.local\bin'
+ $claudeBin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
+
+ # Verified here rather than left for a later step to discover. Assuming the install
+ # location cost a probe run: the install succeeded, `claude` was simply not on PATH, and
+ # the failure two steps later read as the agent being missing rather than as a wrong PATH
+ # entry. Failing at the point the assumption is made is the difference.
+ $claudeExe = Join-Path $claudeBin 'claude.exe'
+ if (-not (Test-Path -LiteralPath $claudeExe)) {
+ Write-Output "installer output above reports where it landed; searching the profile:"
+ Get-ChildItem -Path $env:USERPROFILE -Filter claude.exe -Recurse -ErrorAction SilentlyContinue |
+ Select-Object -First 5 -ExpandProperty FullName
+ throw "claude.exe is not at $claudeExe; the install location has moved"
+ }
+ Write-Output "claude installed at $claudeExe"
- name: Report the environment the probe ran in
run: |
diff --git a/beacon-sandbox/dispatch/dispatch.go b/beacon-sandbox/dispatch/dispatch.go
index 362bf86f..5376ccb9 100644
--- a/beacon-sandbox/dispatch/dispatch.go
+++ b/beacon-sandbox/dispatch/dispatch.go
@@ -182,6 +182,15 @@ func runGH(args ...string) (string, error) {
return string(out), err
}
+// firstLine keeps a retry message to one line. A gh failure can be several lines of connection
+// advice, and repeating all of it on every poll would bury the progress it is interleaved with.
+func firstLine(s string) string {
+ if i := strings.IndexByte(s, '\n'); i >= 0 {
+ return strings.TrimSpace(s[:i])
+ }
+ return strings.TrimSpace(s)
+}
+
// runIDPattern guards against a malformed id reaching a URL or a path. gh returns numeric ids;
// anything else means the output shape changed and should be reported, not interpolated.
var runIDPattern = regexp.MustCompile(`^[0-9]+$`)
@@ -243,16 +252,29 @@ func latestRunID(opts Options) (int64, error) {
// while we poll, we follow the earlier one -- ours.
func awaitNewRun(opts Options, before int64, logf func(string, ...any)) (string, error) {
deadline := time.Now().Add(5 * time.Minute)
+ var lastErr error
for time.Now().Before(deadline) {
runs, err := listRuns(opts, 10)
if err != nil {
- return "", err
+ // Transient rather than fatal. A single failed API call used to abandon a run that was
+ // proceeding perfectly well, and the dispatch reported failure while the workflow it had
+ // just started went on to finish unobserved. Retried until the deadline, with the last
+ // error kept so a persistent outage still reports the real cause rather than a timeout.
+ lastErr = err
+ logf("could not list runs (%v); retrying", firstLine(err.Error()))
+ time.Sleep(5 * time.Second)
+ continue
}
+ lastErr = nil
if found := pickNewRun(runs, before); found > 0 {
return fmt.Sprint(found), nil
}
time.Sleep(5 * time.Second)
}
+ if lastErr != nil {
+ return "", fmt.Errorf("could not reach the GitHub API while waiting for a new %s run: %w",
+ Workflow, lastErr)
+ }
return "", fmt.Errorf("no new %s run appeared within 5 minutes of dispatching; check "+
"`gh run list --workflow %s`", Workflow, Workflow)
}
@@ -293,11 +315,19 @@ func maxRunID(runs []ghRun) int64 {
func awaitCompletion(opts Options, runID string, logf func(string, ...any)) (string, error) {
deadline := time.Now().Add(opts.Timeout)
lastStatus := ""
+ var lastErr error
for time.Now().Before(deadline) {
runs, err := listRuns(opts, 20)
if err != nil {
- return "", err
+ // Same reasoning as awaitNewRun: a blip on the way to api.github.com must not discard a
+ // run that is doing fine. This loop can be waiting 20+ minutes, so the odds of hitting
+ // one are correspondingly higher.
+ lastErr = err
+ logf("could not list runs (%v); retrying", firstLine(err.Error()))
+ time.Sleep(opts.PollInterval)
+ continue
}
+ lastErr = nil
for _, r := range runs {
if fmt.Sprint(r.DatabaseID) != runID {
continue
@@ -312,6 +342,10 @@ func awaitCompletion(opts Options, runID string, logf func(string, ...any)) (str
}
time.Sleep(opts.PollInterval)
}
+ if lastErr != nil {
+ return "", fmt.Errorf("could not reach the GitHub API while waiting for run %s (still "+
+ "running at %s): %w", runID, runURL(opts.Repo, runID), lastErr)
+ }
return "", fmt.Errorf("run %s did not complete within %s; it may still be going at %s",
runID, opts.Timeout, runURL(opts.Repo, runID))
}
diff --git a/beacon-sandbox/image/image.go b/beacon-sandbox/image/image.go
index 7ff9751f..277266aa 100644
--- a/beacon-sandbox/image/image.go
+++ b/beacon-sandbox/image/image.go
@@ -77,8 +77,12 @@ func WindowsLayout() Layout {
AgentHome: home,
WorkDir: `C:\beacon-sandbox\work`,
BeaconDir: beaconDir,
- // The agent installs to %LOCALAPPDATA%\Programs, which is where install.ps1 puts it.
- PathPrepend: []string{beaconDir, filepath.Join(home, "AppData", "Local", "Programs", "claude")},
+ // install.ps1 puts the agent in %USERPROFILE%\.local\bin -- the same ~/.local/bin
+ // convention the Linux image uses, not a Windows-specific Programs directory. Assuming
+ // otherwise cost a probe run: the install succeeded, `claude` was not on PATH, and the
+ // failure read as the agent being missing rather than as a wrong PATH entry. The
+ // installer prints its location, and this matches what it printed.
+ PathPrepend: []string{beaconDir, filepath.Join(home, ".local", "bin")},
}
}