#68468 closed defect (fixed)

cloudflared @2023.8.2 @2023.10.0 build fails: does not build with Go 1.21

Reported by: michiow Owned by: i0ntempest
Priority: Normal Milestone:
Component: ports Version: 2.8.1
Keywords: Cc:
Port: cloudflared

Description

Building cloudflared 2023.8.2 fails with the following messages:

--->  Building cloudflared
Error: Failed to build cloudflared: command execution failed
Error: See /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_cloudflared/cloudflared/main.log for details.
Error: Follow https://guide.macports.org/#project.tickets if you believe there is a bug.

Messages in main.log:

:info:build vendor/github.com/quic-go/quic-go/internal/qtls/go121.go:5:13: cannot use "The version of quic-go you're using can't be built on Go 1.21 yet. For more details, please see https://github.com/quic-go/quic-go/wiki/quic-go-and-Go-versions." (untyped string constant "The version of quic-go you're using can't be built on Go 1.21 yet. F...) as int value in variable declaration
:info:build Command failed:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_cloudflared/cloudflared/work/gopath/src/github.com/cloudflare/cloudflared" && /opt/local/bin/go build -ldflags="-X 'main.Version=2023.8.2' -X 'main.BuildTime=2023-10-14-1559 BST'" -o ./cloudflared ./cmd/cloudflared

"The version of quic-go you're using can't be built on Go 1.21 yet. For more details, please see https://github.com/quic-go/quic-go/wiki/quic-go-and-Go-versions."

The current Go version is 1.21.3:

$ port list cloudflared go
cloudflared                    @2023.8.2       net/cloudflared
go                             @1.21.3         lang/go

Apparently related to the following cloudflared issue: https://github.com/cloudflare/cloudflared/issues/1054

Change History (10)

comment:1 Changed 12 months ago by michiow

Summary: cloudflared @2023.8.2: does not build with Go 1.21cloudflared @2023.8.2 @2023.10.0 build fails: does not build with Go 1.21

Port cloudflared has updated to @2023.10.0 yet the problem still persists.

I know this is an upstream issue with cloudflared, but why continue to release updates that cannot be installed with macports?

comment:2 Changed 12 months ago by i0ntempest

You can easily downgrade go to 1.20 by grabbing the old portfile here: https://github.com/macports/macports-ports/commit/079f0c0e7d498748f01a461cc3d0ffe04442fa8a

comment:3 in reply to:  2 Changed 12 months ago by michiow

Replying to i0ntempest:

You can easily downgrade go to 1.20 by grabbing the old portfile here: https://github.com/macports/macports-ports/commit/079f0c0e7d498748f01a461cc3d0ffe04442fa8a

Sure, but then to avoid having to repeat this workaround I'll have to remember to keep the older Go version, and to activate it for future upgrades.

And it doesn't alter the fact that the cloudflared build is broken under the current release of macports. I suggest you at least update the port info to advise users about the issue.

It looks like the corresponding package in Homebrew has pinned the build dependency to Go 1.20. Can I assume this isn't so easy to do under macports?

Last edited 12 months ago by michiow (previous) (diff)

comment:4 Changed 11 months ago by hwinkler (Hugh Winkler)

Is that our official answer? won't fix?

comment:5 Changed 11 months ago by i0ntempest

Until upstream adds compatibility there's no way it can be fixed in MacPorts, and I am not willing to hold version on this as old versions could have security holes. If the next version still has no support of Go 1.21 I'll add a version check to stop the build if Go version is too new.

comment:6 in reply to:  5 ; Changed 11 months ago by hwinkler (Hugh Winkler)

Replying to i0ntempest:

Until upstream adds compatibility there's no way it can be fixed in MacPorts, and I am not willing to hold version on this as old versions could have security holes. If the next version still has no support of Go 1.21 I'll add a version check to stop the build if Go version is too new.

But as it stands now, we are stuck on the old version of cloudflared, right? With whatever vulnerabilities it might have? I don't know enough about Macports to dispute what you say, I'm just surprised it's not possible to force installation of an older Go version so we can use the most current cloudflared.

Thanks for maintaining this port!

comment:7 in reply to:  6 Changed 11 months ago by i0ntempest

Replying to hwinkler:

Replying to i0ntempest:

Until upstream adds compatibility there's no way it can be fixed in MacPorts, and I am not willing to hold version on this as old versions could have security holes. If the next version still has no support of Go 1.21 I'll add a version check to stop the build if Go version is too new.

But as it stands now, we are stuck on the old version of cloudflared, right? With whatever vulnerabilities it might have? I don't know enough about Macports to dispute what you say, I'm just surprised it's not possible to force installation of an older Go version so we can use the most current cloudflared.

Thanks for maintaining this port!

MacPorts on its own does not allow installation of old port versions, this is by design. But as I stated above it is possible to rollback port version by grabbing the old portfile. Take a look here for detailed instructions: https://trac.macports.org/wiki/howto/InstallingOlderPort, but instead of cloning the whole repo you may use the link I posted above.

comment:8 Changed 11 months ago by michiow

As an interim solution, might it be possible to install Go 1.20 into the working directory at build time?

It seems that Go can self-install an older version of itself: https://go.dev/doc/manage-install#installing-multiple

comment:9 Changed 11 months ago by michiow

I've had a go at modifying the Portfile to install Go 1.20 in the working directory using a pre-build step, and got it to build and install locally with these additions:

--- Portfile.orig	2023-12-03 12:48:39
+++ Portfile	2023-12-03 12:48:45
@@ -590,6 +590,15 @@
               ${gopath}/src/github.com/cloudflare/cloudflared/config/configuration.go
 }
 
+# Install Go 1.20 in the working directory
+set goversion go1.20.11
+pre-build {
+    system "GOPATH=${gopath} go install golang.org/dl/${goversion}@latest"
+    system "HOME=${workpath} ${gopath}/bin/${goversion} download"
+}
+# Override the Go binary used by the build
+set go.bin "${workpath}/sdk/${goversion}/bin/go"
+
 destroot {
     xinstall -m 0755 ${worksrcpath}/${name} ${destroot}${prefix}/bin/
 }

The first command fetches an installer for Go 1.20 and the second executes it, installing under ${workpath}/sdk/go1.20/. The 'download' command seems to always install the SDK under $HOME, so override that to set the install location.

comment:10 Changed 10 months ago by i0ntempest

Resolution: fixed
Status: assignedclosed

In ac1d6f402b6fe01d49d1b21dd9d098e3c6c997b8/macports-ports (master):

cloudflared: 2024.1.1

Closes: #68468

Note: See TracTickets for help on using tickets.