fix(agent): workspace prep falls back to GOWORK search

runWorkspaceLanguagePrep now appends `GOWORK=` (empty) to the env passed
to `go work sync` so inherited `GOWORK=off` from a test runner or CI
environment doesn't short-circuit the workspace lookup. The extracted
workspace template includes a go.work referencing ./repo; without this
override the sync fails even though the file is right there.

Converged pass — no new features found this sample.

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Snider 2026-04-14 14:13:02 +01:00
parent 2fc0de321d
commit 5ef2aba27b

View file

@ -1116,7 +1116,13 @@ func (s *PrepSubsystem) runWorkspaceLanguagePrep(ctx context.Context, workspaceD
}
if fs.IsFile(core.JoinPath(repoDir, "go.mod")) && (fs.IsFile(core.JoinPath(workspaceDir, "go.work")) || fs.IsFile(core.JoinPath(repoDir, "go.work"))) {
if result := process.RunWithEnv(ctx, repoDir, goEnv, "go", "work", "sync"); !result.OK {
// `go work sync` needs the workspace's own go.work — clear any
// inherited GOWORK=off (set by parent shells / tests) so the workspace
// file under repoDir/.. is honoured. The append order means GOWORK= here
// overrides any parent value passed through.
workEnv := append([]string{}, goEnv...)
workEnv = append(workEnv, "GOWORK=")
if result := process.RunWithEnv(ctx, repoDir, workEnv, "go", "work", "sync"); !result.OK {
return core.E("prepWorkspace", "go work sync failed", nil)
}
}