Skip to content

Fix Go runtime setup failure when go.mod doesn't exist - #5583

Merged
pelikhan merged 7 commits into
mainfrom
copilot/fix-go-runtime-setup-bug
Dec 5, 2025
Merged

Fix Go runtime setup failure when go.mod doesn't exist#5583
pelikhan merged 7 commits into
mainfrom
copilot/fix-go-runtime-setup-bug

Conversation

CopilotAI commented Dec 4, 2025

Copy link
Copy Markdown
Contributor
  • Updated DefaultGoVersion constant from 1.23 to 1.25
  • Updated unit tests to expect version 1.25
  • Updated integration tests to expect version 1.25
  • Recompiled workflow lock files with new Go version
  • All tests passing
Original prompt

This section details on the original issue you should resolve

<issue_title>Bug: Go runtime setup fails when go.mod doesn't exist</issue_title>
<issue_description>## Problem

The compiler automatically adds a "Setup Go" step when it detects Go commands (e.g., go version in custom steps or Serena Go language service), but this step fails if the repository doesn't have a go.mod file.

Root Cause

In pkg/workflow/runtime_setup.go:

  1. Go runtime definition (lines 77-84):

    {
    ID: "go",
    Name: "Go",
    ActionRepo: "actions/setup-go",
    ActionVersion: "v5",
    VersionField: "go-version",
    DefaultVersion: "", // Special handling: uses go.modCommands: []string{"go"},
    }
  2. Setup step generation (lines 575-583):

    ifruntime.ID=="go"&& (version==""||req.GoModFile!="") {
    step=append(step, " with:")
    goModPath:="go.mod"// ⚠️ Assumes go.mod existsifreq.GoModFile!="" {
    goModPath=req.GoModFile
    }
    step=append(step, fmt.Sprintf(" go-version-file: %s", goModPath))
    step=append(step, " cache: true")
    // ...
    }

Result: The generated workflow uses go-version-file: go.mod, which fails if the file doesn't exist:

Error: The specified go version file at: go.mod does not exist

Steps to Reproduce

  1. Create a workflow that uses Claude with Serena Go language service or has a custom step with go version
  2. Run it in a repository without a go.mod file
  3. The workflow fails during the "Setup Go" step

Proposed Fix

Add a default Go version and use it as a fallback:

  1. Add to pkg/constants/constants.go:

    // DefaultGoVersion is the default version of Go for runtime setupconstDefaultGoVersionVersion="1.23"
  2. Update pkg/workflow/runtime_setup.go:82:

    DefaultVersion: string(constants.DefaultGoVersion),
  3. Update logic at runtime_setup.go:575 to only use go-version-file when explicitly specified:

    ifruntime.ID=="go"&&req.GoModFile!="" {
    // Only use go-version-file if explicitly specifiedstep=append(step, " with:")
    step=append(step, fmt.Sprintf(" go-version-file: %s", req.GoModFile))
    step=append(step, " cache: true")
    } elseifversion!="" {
    // Use explicit versionstep=append(step, " with:")
    step=append(step, fmt.Sprintf(" go-version: '%s'", version))
    }

This way:

  • Repos withgo.mod can explicitly specify go-mod-file in frontmatter
  • Repos withoutgo.mod will use the default Go version
  • Users can still override with explicit version in frontmatter

Related Code

  • Detection:pkg/workflow/compiler_yaml.go:246 calls DetectRuntimeRequirements()
  • Generation:pkg/workflow/compiler_yaml.go:263 calls GenerateRuntimeSetupSteps()
  • Runtime setup:pkg/workflow/runtime_setup.go:169-224 (detection) and pkg/workflow/runtime_setup.go:443-453 (generation)</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

CopilotAIand others added 4 commits December 4, 2025 23:57
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
CopilotAI changed the title [WIP] Fix Go runtime setup failure when go.mod is missingFix Go runtime setup failure when go.mod doesn't existDec 5, 2025
CopilotAI requested a review from pelikhanDecember 5, 2025 00:16
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot Default version 1.25

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

CopilotAI commented Dec 5, 2025

Copy link
Copy Markdown
ContributorAuthor

@copilot Default version 1.25

Updated default Go version to 1.25 in commit be83d9a

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot recompile

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

CopilotAI commented Dec 5, 2025

Copy link
Copy Markdown
ContributorAuthor

@copilot recompile

Recompiled workflow lock files in commit 90877a3. Updated 15 lock files with Go version 1.25.

@pelikhan
pelikhan marked this pull request as ready for review December 5, 2025 01:32
@pelikhan
pelikhan merged commit d175957 into mainDec 5, 2025
50 of 51 checks passed
@pelikhan
pelikhan deleted the copilot/fix-go-runtime-setup-bug branch December 5, 2025 01:33
Sign up for freeto 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.

Bug: Go runtime setup fails when go.mod doesn't exist

2 participants

@pelikhan