flyctl
flyctl copied to clipboard
unable to build on FreeBSD
Describe the bug
I'd like to get flyctl into FreeBSD ports tree. The first step is to compile from source, which fails:
### boot a FreeBSD 13.0-RELEASE image somewhere and get root
$ sudo -s
### install latest go and git tools from packages
# sed -i '' -e 's/quarterly/latest/' /etc/pkg/FreeBSD.conf
# pkg install -y lang/go devel/gmake git-tiny
# exit
### switch back to non-root
$ git clone https://github.com/superfly/flyctl
$ cd flyctl && gmake
% gmake build
Running Generate for Help
go generate ./...
generating cli help
Running Build
go build -o bin/flyctl -ldflags="-X 'github.com/superfly/flyctl/internal/buildinfo.buildDate=2022-01-06T09:59:32Z'" .
# github.com/buildpacks/lifecycle/cmd
../pkg/mod/github.com/buildpacks/[email protected]/cmd/flags.go:14:41: undefined: rootDir
../pkg/mod/github.com/buildpacks/[email protected]/cmd/flags.go:15:41: undefined: rootDir
../pkg/mod/github.com/buildpacks/[email protected]/cmd/flags.go:17:41: undefined: rootDir
../pkg/mod/github.com/buildpacks/[email protected]/cmd/flags.go:17:81: undefined: execExt
../pkg/mod/github.com/buildpacks/[email protected]/cmd/flags.go:18:41: undefined: rootDir
../pkg/mod/github.com/buildpacks/[email protected]/cmd/flags.go:21:41: undefined: rootDir
../pkg/mod/github.com/buildpacks/[email protected]/cmd/flags.go:23:41: undefined: rootDir
../pkg/mod/github.com/buildpacks/[email protected]/cmd/flags.go:128:32: undefined: rootDir
# github.com/buildpacks/lifecycle/archive
../pkg/mod/github.com/buildpacks/[email protected]/archive/archive.go:45:2: undefined: addSysAttributes
../pkg/mod/github.com/buildpacks/[email protected]/archive/extract.go:21:11: undefined: setUmask
../pkg/mod/github.com/buildpacks/[email protected]/archive/extract.go:22:8: undefined: setUmask
../pkg/mod/github.com/buildpacks/[email protected]/archive/extract.go:68:14: undefined: createSymlink
# github.com/buildpacks/lifecycle/launch
../pkg/mod/github.com/buildpacks/[email protected]/launch/exec_d.go:40:13: undefined: setHandle
../pkg/mod/github.com/buildpacks/[email protected]/launch/launch.go:25:41: undefined: exe
../pkg/mod/github.com/buildpacks/[email protected]/launch/launcher.go:16:31: undefined: CNBDir
../pkg/mod/github.com/buildpacks/[email protected]/launch/launcher.go:17:31: undefined: CNBDir
../pkg/mod/github.com/buildpacks/[email protected]/launch/launcher.go:18:56: undefined: exe
../pkg/mod/github.com/buildpacks/[email protected]/launch/shell.go:54:45: undefined: appProfile
../pkg/mod/github.com/buildpacks/[email protected]/launch/shell.go:58:122: undefined: appProfile
../pkg/mod/github.com/buildpacks/[email protected]/launch/shell.go:61:31: undefined: appProfile
# github.com/docker/docker/pkg/system
../pkg/mod/github.com/docker/[email protected]+incompatible/pkg/system/mknod.go:12:19: cannot use dev (type int) as type uint64 in argument to unix.Mknod
# github.com/tonistiigi/fsutil
../pkg/mod/github.com/tonistiigi/[email protected]/diskwriter_unix.go:48:41: cannot use int(mkdev(stat.Devmajor, stat.Devminor)) (type int) as type uint64 in argument to syscall.Mknod
gmake: *** [Makefile:11: build] Error 2
%
not familiar enough with go to know if this is fixable or not.
I tried an alternative approach, from Dockerfile.dev, yielding same results:
$ go build -o /flyctl -ldflags="-X 'github.com/superfly/flyctl/internal/buildinfo.buildDate=NOW_RFC3339'" .
# github.com/buildpacks/lifecycle/archive
../pkg/mod/github.com/buildpacks/[email protected]/archive/archive.go:45:2: undefined: addSysAttributes
../pkg/mod/github.com/buildpacks/[email protected]/archive/extract.go:21:11: undefined: setUmask
../pkg/mod/github.com/buildpacks/[email protected]/archive/extract.go:22:8: undefined: setUmask
../pkg/mod/github.com/buildpacks/[email protected]/archive/extract.go:68:14: undefined: createSymlink
# github.com/buildpacks/lifecycle/launch
../pkg/mod/github.com/buildpacks/[email protected]/launch/exec_d.go:40:13: undefined: setHandle
../pkg/mod/github.com/buildpacks/[email protected]/launch/launch.go:25:41: undefined: exe
../pkg/mod/github.com/buildpacks/[email protected]/launch/launcher.go:16:31: undefined: CNBDir
../pkg/mod/github.com/buildpacks/[email protected]/launch/launcher.go:17:31: undefined: CNBDir
../pkg/mod/github.com/buildpacks/[email protected]/launch/launcher.go:18:56: undefined: exe
../pkg/mod/github.com/buildpacks/[email protected]/launch/shell.go:54:45: undefined: appProfile
../pkg/mod/github.com/buildpacks/[email protected]/launch/shell.go:58:122: undefined: appProfile
../pkg/mod/github.com/buildpacks/[email protected]/launch/shell.go:61:31: undefined: appProfile
# github.com/buildpacks/lifecycle/cmd
../pkg/mod/github.com/buildpacks/[email protected]/cmd/flags.go:14:41: undefined: rootDir
../pkg/mod/github.com/buildpacks/[email protected]/cmd/flags.go:15:41: undefined: rootDir
../pkg/mod/github.com/buildpacks/[email protected]/cmd/flags.go:17:41: undefined: rootDir
../pkg/mod/github.com/buildpacks/[email protected]/cmd/flags.go:17:81: undefined: execExt
../pkg/mod/github.com/buildpacks/[email protected]/cmd/flags.go:18:41: undefined: rootDir
../pkg/mod/github.com/buildpacks/[email protected]/cmd/flags.go:21:41: undefined: rootDir
../pkg/mod/github.com/buildpacks/[email protected]/cmd/flags.go:23:41: undefined: rootDir
../pkg/mod/github.com/buildpacks/[email protected]/cmd/flags.go:128:32: undefined: rootDir
# github.com/tonistiigi/fsutil
../pkg/mod/github.com/tonistiigi/[email protected]/diskwriter_unix.go:48:41: cannot use int(mkdev(stat.Devmajor, stat.Devminor)) (type int) as type uint64 in argument to syscall.Mknod
# github.com/docker/docker/pkg/system
../pkg/mod/github.com/docker/[email protected]+incompatible/pkg/system/mknod.go:12:19: cannot use dev (type int) as type uint64 in argument to unix.Mknod
$
Hi there, we're currently depending on lifecycle which does not currently build on FreeBSD (ref) - this is what breaks your build. Additionally, I also suspect that some other libraries (docker, as an example) might break when trying to build on FreeBSD :(.
I don't understand why we need a full docker + other libraries in flyctl just so I can set secrets and boot apps... is it possible to use some API directly, instead?
@dch hey, do you still need help with this?
Yep it would be handy still. I moved my stuff off fly for the moment because of the missing tooling.
On Fri, 1 Sep 2023, at 23:15, Redjon Zaci wrote:
@dch https://github.com/dch hey, do you still need help with this?
— Reply to this email directly, view it on GitHub https://github.com/superfly/flyctl/issues/712#issuecomment-1703327038, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACFNUH2LAQ6N2EWNWZYQPTXYJF7ZANCNFSM5LL6KMFA. You are receiving this because you were mentioned.Message ID: @.***>
@dch could you maybe try building again to see if it now works? I could get on FreeBSD and test this, but would take more time.
we get a bit further:
$ gmake build
Running Generate for Help and GraphQL client
go generate ./...
go: downloading github.com/azazeal/pause v1.3.0
go: downloading github.com/cenkalti/backoff/v4 v4.2.0
go: downloading github.com/google/go-querystring v1.1.0
go: downloading github.com/samber/lo v1.38.1
go: downloading github.com/cenkalti/backoff v2.2.1+incompatible
go: downloading golang.org/x/sync v0.3.0
go: downloading github.com/Khan/genqlient v0.6.0
go: downloading github.com/vektah/gqlparser v1.3.1
go: downloading github.com/jinzhu/copier v0.3.5
go: downloading github.com/BurntSushi/toml v1.3.2
go: downloading github.com/PuerkitoBio/rehttp v1.2.0
go: downloading github.com/ndarilek/calver-go v0.0.0-20230710153822-893bbd83a936
go: downloading github.com/buildpacks/pack v0.30.0
go: downloading github.com/AlecAivazis/survey/v2 v2.3.7
go: downloading github.com/MakeNowJust/heredoc/v2 v2.0.1
go: downloading github.com/containerd/console v1.0.3
go: downloading github.com/docker/docker v24.0.5+incompatible
go: downloading github.com/superfly/graphql v0.2.4
go: downloading golang.org/x/term v0.11.0
go: downloading golang.org/x/net v0.14.0
go: downloading github.com/miekg/dns v1.1.55
go: downloading github.com/moby/buildkit v0.11.6
go: downloading golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63
go: downloading github.com/moby/patternmatcher v0.5.0
go: downloading github.com/vektah/gqlparser/v2 v2.5.6
go: downloading google.golang.org/grpc v1.57.0
go: downloading golang.org/x/sys v0.11.0
go: downloading golang.org/x/crypto v0.12.0
go: downloading github.com/cavaliergopher/grab/v3 v3.0.1
go: downloading github.com/cli/safeexec v1.0.1
go: downloading github.com/muesli/termenv v0.15.2
go: downloading github.com/getsentry/sentry-go v0.23.0
go: downloading golang.zx2c4.com/wireguard v0.0.0-20230325221338-052af4a8072b
go: downloading nhooyr.io/websocket v1.8.7
go: downloading github.com/haileys/go-harlog v0.0.0-20230517070437-0f99204b5a57
go: downloading github.com/mattn/go-zglob v0.0.4
go: downloading github.com/ejcx/sshcert v1.1.0
go: downloading github.com/pkg/sftp v1.13.6
go: downloading golang.org/x/text v0.12.0
go: downloading github.com/buildpacks/lifecycle v0.17.0
go: downloading github.com/docker/go-units v0.5.0
go: downloading github.com/buildpacks/imgutil v0.0.0-20230626185301-726f02e4225c
go: downloading github.com/google/go-containerregistry v0.16.1
go: downloading github.com/opencontainers/image-spec v1.1.0-rc4
go: downloading github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06
go: downloading github.com/moby/term v0.5.0
go: downloading github.com/containerd/containerd v1.7.2
go: downloading github.com/klauspost/compress v1.16.5
go: downloading github.com/moby/sys/sequential v0.5.0
go: downloading github.com/sirupsen/logrus v1.9.3
go: downloading github.com/heroku/heroku-go/v5 v5.5.0
go: downloading github.com/docker/distribution v2.8.2+incompatible
go: downloading github.com/nats-io/nats.go v1.28.0
go: downloading github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
go: downloading go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.40.0
go: downloading go.opentelemetry.io/otel v1.14.0
go: downloading go.opentelemetry.io/otel/trace v1.14.0
go: downloading github.com/tonistiigi/fsutil v0.0.0-20230407161946-9e7a6df48576
go: downloading go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.14.0
go: downloading go.opentelemetry.io/otel/sdk v1.14.0
go: downloading gvisor.dev/gvisor v0.0.0-20230504175454-7b0a1988a28f
go: downloading google.golang.org/genproto/googleapis/rpc v0.0.0-20230803162519-f966b187b2e5
go: downloading google.golang.org/genproto v0.0.0-20230807174057-1744710a1577
go: downloading github.com/go-git/go-git/v5 v5.8.1
go: downloading golang.org/x/mod v0.12.0
go: downloading github.com/gdamore/tcell/v2 v2.6.0
go: downloading github.com/rivo/tview v0.0.0-20220307222120-9994674d60a8
go: downloading github.com/opencontainers/selinux v1.11.0
go: downloading github.com/docker/cli v24.0.5+incompatible
go: downloading github.com/opencontainers/runc v1.1.7
go: downloading github.com/nats-io/nkeys v0.4.4
go: downloading github.com/golang/protobuf v1.5.3
go: downloading google.golang.org/protobuf v1.31.0
go: downloading github.com/moby/sys/signal v0.7.0
go: downloading go.opentelemetry.io/proto/otlp v0.19.0
go: downloading go.opentelemetry.io/otel/metric v0.37.0
go: downloading github.com/hashicorp/errwrap v1.1.0
go: downloading github.com/containerd/continuity v0.4.1
go: downloading github.com/containerd/stargz-snapshotter/estargz v0.14.3
go: downloading github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20230522190001-adf1bafd791a
go: downloading github.com/chrismellard/docker-credential-acr-env v0.0.0-20230304212654-82a0ddb27589
go: downloading github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95
go: downloading github.com/emirpasic/gods v1.18.1
go: downloading dario.cat/mergo v1.0.0
go: downloading github.com/go-git/go-billy/v5 v5.4.1
go: downloading github.com/sergi/go-diff v1.3.1
go: downloading github.com/vbatts/tar-split v0.11.3
go: downloading github.com/docker/docker-credential-helpers v0.7.0
go: downloading github.com/Azure/go-autorest/autorest/azure/auth v0.5.12
go: downloading github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376
go: downloading github.com/Azure/go-autorest/autorest v0.11.29
go: downloading github.com/pjbgf/sha1cd v0.3.0
go: downloading github.com/agext/levenshtein v1.2.3
go: downloading github.com/Azure/go-autorest v14.2.0+incompatible
go: downloading github.com/containerd/typeurl/v2 v2.1.1
go: downloading github.com/aws/aws-sdk-go-v2 v1.18.1
go: downloading github.com/aws/aws-sdk-go-v2/config v1.18.27
go: downloading github.com/aws/aws-sdk-go-v2/service/ecr v1.18.11
go: downloading github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.16.2
go: downloading github.com/aws/smithy-go v1.13.5
go: downloading github.com/Azure/azure-sdk-for-go v68.0.0+incompatible
go: downloading github.com/Azure/go-autorest/autorest/adal v0.9.23
go: downloading github.com/cloudflare/circl v1.3.3
go: downloading github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
go: downloading github.com/kevinburke/ssh_config v1.2.0
go: downloading github.com/skeema/knownhosts v1.2.0
go: downloading github.com/xanzy/ssh-agent v0.3.3
go: downloading github.com/Azure/go-autorest/autorest/azure/cli v0.4.6
go: downloading github.com/Azure/go-autorest/logger v0.2.1
go: downloading github.com/dimchansky/utfbom v1.1.1
go: downloading github.com/aws/aws-sdk-go-v2/credentials v1.13.26
go: downloading github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.4
go: downloading github.com/aws/aws-sdk-go-v2/internal/ini v1.3.35
go: downloading github.com/aws/aws-sdk-go-v2/service/sso v1.12.12
go: downloading github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.12
go: downloading github.com/aws/aws-sdk-go-v2/service/sts v1.19.2
go: downloading github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.34
go: downloading github.com/Azure/go-autorest/tracing v0.6.0
go: downloading github.com/golang-jwt/jwt/v4 v4.5.0
go: downloading github.com/Azure/go-autorest/autorest/date v0.3.0
go: downloading github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.28
go: downloading github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.28
go: downloading google.golang.org/genproto/googleapis/api v0.0.0-20230803162519-f966b187b2e5
go: downloading golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846
Running Build
CGO_ENABLED=0 go build -o bin/flyctl -ldflags="-X 'github.com/superfly/flyctl/internal/buildinfo.buildDate=2023-09-05T21:08:03Z' -X 'github.com/superfly/flyctl/internal/buildinfo.branchName=master'" .
internal/command/migrate_to_v2/migrate_to_v2.go:4:2: package cmp is not in GOROOT (/usr/local/go120/src/cmp)
note: imported by a module that requires go 1.21
package github.com/superfly/flyctl
imports github.com/superfly/flyctl/internal/cli
imports github.com/superfly/flyctl/internal/command/root
imports github.com/superfly/flyctl/internal/command/consul
imports github.com/superfly/flyctl/internal/command/secrets
imports github.com/superfly/flyctl/internal/command/deploy
imports github.com/superfly/flyctl/internal/build/imgsrc
imports github.com/buildpacks/pack/pkg/client
imports github.com/buildpacks/lifecycle
imports github.com/buildpacks/lifecycle/cache
imports github.com/buildpacks/lifecycle/platform
imports github.com/buildpacks/lifecycle/internal/path: build constraints exclude all Go files in /home/dch/go/pkg/mod/github.com/buildpacks/[email protected]/internal/path
api/client.go:12:2: package slices is not in GOROOT (/usr/local/go120/src/slices)
gmake: *** [Makefile:12: build] Error 1
and
gmake
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-09-05T21:09:31Z' -X 'github.com/superfly/flyctl/internal/buildinfo.branchName=master'" .
internal/command/migrate_to_v2/migrate_to_v2.go:4:2: package cmp is not in GOROOT (/usr/local/go120/src/cmp)
note: imported by a module that requires go 1.21
package github.com/superfly/flyctl
imports github.com/superfly/flyctl/internal/cli
imports github.com/superfly/flyctl/internal/command/root
imports github.com/superfly/flyctl/internal/command/consul
imports github.com/superfly/flyctl/internal/command/secrets
imports github.com/superfly/flyctl/internal/command/deploy
imports github.com/superfly/flyctl/internal/build/imgsrc
imports github.com/buildpacks/pack/pkg/client
imports github.com/buildpacks/lifecycle
imports github.com/buildpacks/lifecycle/cache
imports github.com/buildpacks/lifecycle/platform
imports github.com/buildpacks/lifecycle/internal/path: build constraints exclude all Go files in /home/dch/go/pkg/mod/github.com/buildpacks/[email protected]/internal/path
api/client.go:12:2: package slices is not in GOROOT (/usr/local/go120/src/slices)
gmake: *** [Makefile:12: build] Error 1
@dch thank you! I am no expert in this, but it seems like you are using Go 1.20? If so, could you try upgrading to 1.21?
I noticed this line: note: imported by a module that requires go 1.21.
sure:
$ go version
go version go1.21.0 freebsd/amd64
$ gmake
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-09-06T10:24:28Z' -X 'github.com/superfly/flyctl/internal/buildinfo.branchName=master'" .
package github.com/superfly/flyctl
imports github.com/superfly/flyctl/internal/cli
imports github.com/superfly/flyctl/internal/command/root
imports github.com/superfly/flyctl/internal/command/consul
imports github.com/superfly/flyctl/internal/command/secrets
imports github.com/superfly/flyctl/internal/command/deploy
imports github.com/superfly/flyctl/internal/build/imgsrc
imports github.com/buildpacks/pack/pkg/client
imports github.com/buildpacks/lifecycle
imports github.com/buildpacks/lifecycle/cache
imports github.com/buildpacks/lifecycle/platform
imports github.com/buildpacks/lifecycle/internal/path: build constraints exclude all Go files in ***@***.***/internal/path
gmake: *** [Makefile:12: build] Error 1
I tried amending @.***/internal/path but same result.
I think there might still be the same problem mentioned here https://github.com/superfly/flyctl/issues/712#issuecomment-1006446445. @azazeal sorry to tag you here, but what do you think?
https://github.com/hut8/lifecycle/tree/hut8/freebsd
I'm getting lifecycle to build on FreeBSD. There was an old branch on there to implement the same stuff, but it was so long ago that there are merge conflicts and I can't even see the CI logs.
In the meantime, is lifecycle actually necessary for 100% of flyctl's functionality? I just want to run a deploy with --remote-only or something - would you accept a PR that would not include local docker features?
would you accept a PR that would not include local docker features?
how is that going to work? guard FreeBSD incompatible features with build tags?
I can't promise to merge such thing but I don't mind to evaluate once it is clear what is needed.
So I think that I might just be able to add FreeBSD support to lifecycle -- it's a huge pain but I'm making progress. Clearly this is a better solution than having a half-baked FreeBSD binary, but even that would be better than what we have now (nothing).