Skip to content

Fix build with older installed golang versions#2664

Open
lkolbly wants to merge 1 commit intoreplicate:mainfrom
lkolbly:lkolbly/fix-linux-build
Open

Fix build with older installed golang versions#2664
lkolbly wants to merge 1 commit intoreplicate:mainfrom
lkolbly:lkolbly/fix-linux-build

Conversation

@lkolbly
Copy link

@lkolbly lkolbly commented Jan 29, 2026

I tried building cog on my Linux machine (with make cog), and it failed unless I did these things.

Because of https://stackoverflow.com/questions/78519711/toolchain-not-available-error-prevents-me-from-using-any-go-commands and also because it seems like part of the build step needs some wheels built?

@lkolbly lkolbly requested a review from a team as a code owner January 29, 2026 22:11
@@ -1,9 +1,8 @@
module github.com/replicate/cog

go 1.25
Copy link
Contributor

Choose a reason for hiding this comment

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

undo this please

Copy link
Author

Choose a reason for hiding this comment

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

Ah, no can do mi amigo:

(base) lkolbly@B0K3C14:~/cog$ make cog
... lots of stuff ...
go: downloading go1.25 (linux/amd64)
go: download go1.25 for linux/amd64: toolchain not available
make: *** [Makefile:77: generate] Error 1
(base) lkolbly@B0K3C14:~/cog$ 

Copy link
Member

Choose a reason for hiding this comment

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

@lkolbly how is go installed? what version? this should "just work" since we perform builds and tests in CI on linux

Copy link
Author

Choose a reason for hiding this comment

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

@michaeldwan I have 1.22.3:

(base) lkolbly@B0K3C14:~$ go version
go version go1.22.3 linux/amd64

Installed presumably by following the instructions at go.dev (which is to... manually unpack a tarball? Hmm someone should invent a tool to do that for us :D)

Okay so I'm reading https://go.dev/doc/toolchain#config, and it says that:

If the toolchain line is omitted, the module or workspace is considered to have an implicit toolchain goV line, where V is the Go version from the go line. ... For example, a go.mod that says go 1.21.0 with no toolchain line is interpreted as if it had a toolchain go1.21.0 line.

This is a go.mod with no toolchain line, so I guess presumably the toolchain would default to go1.25?

...but, go1.25 is not a valid toolchain, which is the error I'm seeing:

For example, go1.21rc1 and go1.21.0 are toolchain names; go1.21 and go1.22 are not (the initial releases are go1.21.0 and go1.22.0)

So my reading is that, if you don't have a toolchain file, it's invalid to not specify the full patch version for the language? It's weird that go wouldn't lint that though.

(of course, if you have a higher toolchain installed, then go will just use that - in CI presumably you have at least 1.25 installed, so it doesn't try to install 1.25)

But, I think also, this means that I should set the patch version to 1.25.0 (because otherwise it changes the toolchain (and language?) for people with versions 1.25.0 through 1.25.5), I've updated the PR with this change.

(specifying 1.25.0 does exclude all the RCs, I think, where 1.25 maybe does not. Don't quote me on that)

@lkolbly lkolbly force-pushed the lkolbly/fix-linux-build branch from 4b97b42 to 7a09930 Compare January 30, 2026 16:08
@lkolbly lkolbly force-pushed the lkolbly/fix-linux-build branch from 7a09930 to 7d47a85 Compare January 30, 2026 16:19
@lkolbly lkolbly changed the title Fix build on linux Fix build with older installed golang versions Jan 30, 2026
@lkolbly lkolbly force-pushed the lkolbly/fix-linux-build branch from 7d47a85 to 6769e60 Compare January 30, 2026 16:49
@michaeldwan
Copy link
Member

@lkolbly you're right. the directive should include the release: go 1.25.3. There was a time between go 1.21 and 1.23 where the language version and toolchain versions changed, and we've been blind to the issue by using much newer go versions. Your fix it good and we should add it!

Not sure about the makefile change. @tempusfrangit is streamlining the wheel build and removing all the old sdks and runtimes. This might not be needed anymore if you rebase on main.

Signed-off-by: Lane Kolbly <lkolbly@cloudflare.com>
@lkolbly lkolbly force-pushed the lkolbly/fix-linux-build branch from 6769e60 to bebca5c Compare February 4, 2026 21:54
@lkolbly
Copy link
Author

lkolbly commented Feb 4, 2026

@michaeldwan It's possible that maybe this line is good as-is, but we need a toolchain directive.

But for now, I just updated the PR to 1.25.3 and removed the Makefile change.

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.

3 participants

Comments