Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build 'flyctl' #2748

Closed
usrme opened this issue Aug 29, 2023 · 12 comments
Closed

Unable to build 'flyctl' #2748

usrme opened this issue Aug 29, 2023 · 12 comments
Labels
bug Something isn't working

Comments

@usrme
Copy link
Contributor

usrme commented Aug 29, 2023

Describe the bug

After cloning this repository, I am unable to build the flyctl executable.

  • Operating system: Fedora 37
  • Go: 1.21.0, but had same issue with 1.20.1 too

Command output

$ make build
Running Generate for Help and GraphQL client
go generate ./...
Running Build
CGO_ENABLED=0 go build -o bin/flyctl -ldflags="-X 'github.com/superfly/flyctl/internal/buildinfo.buildDate=2023-08-29T11:24:20Z' -X 'github.com/superfly/flyctl/internal/buildinfo.branchName=master'" .
# github.com/superfly/flyctl/internal/command/migrate_to_v2
internal/command/migrate_to_v2/migrate_to_v2.go:286:26: type func(i *"github.com/superfly/flyctl/api".AllocationStatus, j *"github.com/superfly/flyctl/api".AllocationStatus) bool of func(i, j *api.AllocationStatus) bool {…} does not match inferred type func(a *"github.com/superfly/flyctl/api".AllocationStatus, b *"github.com/superfly/flyctl/api".AllocationStatus) int for func(a E, b E) int
make: *** [Makefile:12: build] Error 1

I'm assuming this is something to do with my machine as it seems like an obvious enough issue that would affect more people.

I've tried removing Go entirely (deleted /usr/local/go and ~/go directories) and re-installing it, but the result is the same. Haven't stumbled onto this issue elsewhere.

@usrme usrme added the bug Something isn't working label Aug 29, 2023
@redjonzaci
Copy link
Contributor

I was able to build the executable with go version go1.21.0 linux/amd64 on a codespace running:

NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"

@usrme
Copy link
Contributor Author

usrme commented Aug 29, 2023

I was able to run scripts/build-dfly just fine, so it is most definitely something awry with my machine, but I'm unsure as to what could even be the culprit here.

@usrme
Copy link
Contributor Author

usrme commented Aug 29, 2023

It looks as if this is the culprit, but why would this be a problem for me and not anyone else? 🤔

golang/go#61374

@redjonzaci
Copy link
Contributor

I wish I could answer that, but maybe someone else can help.

@michaeldwan
Copy link
Contributor

We just merged in support for go 1.21 yesterday. Rebase and you should be good!

@usrme
Copy link
Contributor Author

usrme commented Aug 29, 2023

I just did a full clone of the repository, cleaned both the build cache and the module download cache, but still make build fails as it did before.

@michaeldwan
Copy link
Contributor

Did you update the slices package? The latest version matches the behavior of the new slices package in the stdlib, which returns an int instead of bool from the compare func. I thought I had a PR to replace exp/slices and exp/maps with slices and maps along with fixing usage, but I can't find it!

@usrme
Copy link
Contributor Author

usrme commented Aug 30, 2023

Excuse my ignorance, but I'm having a hard time understanding why I would get anything but a successful build if I:

  • completely wiped Go from my system and re-installed 1.21.0;
  • cleaned the build cache with go clean -cache;
  • cleaned the module download cache with go clean -modcache;
  • did a complete clone of the flyctl repository;
  • navigated into it and ran make build.

At no point did I run any commands to update any of the packages.

@michaeldwan
Copy link
Contributor

For whatever reason the package golang.org/x/exp you have installed is newer than we want. This happened to me last week when I was updating other packages, and I fixed it by reverting my change. No matter, it's an easy fix. Give me ~30 minutes and I'll get it fixed up so you are unblocked.

@usrme
Copy link
Contributor Author

usrme commented Aug 30, 2023

Thanks for trying to sort this out for me, it really means a lot! I did a little more sleuthing and after cleaning the module cache, and running make build, I observed that somewhere down the module resolution line the correct version of golang.org/x/exp is downloaded (i.e. the one in go.mod, i.e. v0.0.0-20230713183714-613f0c0eb8a1). However, right after the building starts:

$ make build
...
Running Build
CGO_ENABLED=0 go build -o bin/flyctl -ldflags="-X 'github.com/superfly/flyctl/internal/buildinfo.buildDate=2023-08-30T18:27:39Z' -X 'github.com/superfly/flyctl/internal/buildinfo.branchName=master'" .
go: downloading github.com/mattn/go-runewidth v0.0.15
go: downloading golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63
go: downloading github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81
go: downloading github.com/containerd/stargz-snapshotter v0.13.0
go: downloading github.com/rivo/uniseg v0.4.4
go: downloading github.com/grpc-ecosystem/grpc-gateway v1.16.0
# github.com/superfly/flyctl/internal/command/migrate_to_v2
internal/command/migrate_to_v2/migrate_to_v2.go:286:26: type func(i *"github.com/superfly/flyctl/api".AllocationStatus, j *"github.com/superfly/flyctl/api".AllocationStatus) bool of func(i, j *api.AllocationStatus) bool {…} does not match inferred type func(a *"github.com/superfly/flyctl/api".AllocationStatus, b *"github.com/superfly/flyctl/api".AllocationStatus) int for func(a E, b E) int
make: *** [Makefile:12: build] Error 1

Where it says go: downloading github.com/grpc-ecosystem/grpc-gateway v1.16.0, it stays for some time to presumably resolve any dependencies and during that time it downloads a newer version of golang.org/x/exp, namely v0.0.0-20230817173708-d852ddb80c63. I'm unsure why this is even happening.

And it's still puzzling to me why the mere existence of this newer version disrupts the build though as shouldn't the version from go.mod be used instead?

@michaeldwan
Copy link
Contributor

I'm sorry that this has been such a slog! The PR that fixes function signatures has been merged. Let me know if you're still having issues with that.

@usrme
Copy link
Contributor Author

usrme commented Aug 31, 2023

You, sir, are a gentleman and a scholar - I'm finally able to build off of the tip thanks to you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants