kubebuilder
kubebuilder copied to clipboard
kubebuilder create api command results in "cgo_linux.go:12:8: no such package located"
What broke? What's expected?
Hi,
i'm new to kubebuilder, i tried the quick-start and stucked in the second step kubebuilder create api --group webapp --version v1 --kind Guestbook.
I would be really grateful for a workaround or a fix.
I've got this messages: It seems that cgo_linux.go:12:8 is missing.
kubebuilder create api --group webapp --version v1 --kind Guestbook
Create Resource [y/n]
y
Create Controller [y/n]
y
Writing kustomize manifests for you to edit...
Writing scaffold for you to edit...
api/v1/guestbook_types.go
controllers/guestbook_controller.go
Update dependencies:
$ go mod tidy
go: downloading github.com/onsi/ginkgo/v2 v2.0.0
Running make:
$ make generate
mkdir -p /home/debian/projects/guestbook/bin
GOBIN=/home/debian/projects/guestbook/bin go install sigs.k8s.io/controller-tools/cmd/[email protected]
go: downloading sigs.k8s.io/controller-tools v0.9.0
go: downloading github.com/spf13/cobra v1.4.0
go: downloading github.com/gobuffalo/flect v0.2.5
go: downloading golang.org/x/tools v0.1.10-0.20220218145154-897bd77cd717
go: downloading github.com/fatih/color v1.12.0
go: downloading github.com/mattn/go-isatty v0.0.12
go: downloading github.com/mattn/go-colorable v0.1.8
go: downloading golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3
/home/debian/projects/guestbook/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
/usr/local/go/src/net/cgo_linux.go:12:8: no such package located
Error: not all generators ran successfully
run `controller-gen object:headerFile=hack/boilerplate.go.txt paths=./... -w` to see all available markers, or `controller-gen object:headerFile=hack/boilerplate.go.txt paths=./... -h` for usage
make: *** [Makefile:48: generate] Error 1
Error: failed to create API: unable to run post-scaffold tasks of "base.go.kubebuilder.io/v3": exit status 2
Usage:
kubebuilder create api [flags]
Examples:
# Create a frigates API with Group: ship, Version: v1beta1 and Kind: Frigate
kubebuilder create api --group ship --version v1beta1 --kind Frigate
# Edit the API Scheme
nano api/v1beta1/frigate_types.go
# Edit the Controller
nano controllers/frigate/frigate_controller.go
# Edit the Controller Test
nano controllers/frigate/frigate_controller_test.go
# Generate the manifests
make manifests
# Install CRDs into the Kubernetes cluster using kubectl apply
make install
# Regenerate code and run against the Kubernetes cluster configured by ~/.kube/config
make run
Flags:
--controller if set, generate the controller without prompting the user (default true)
--force attempt to create resource even if it already exists
--group string resource Group
-h, --help help for api
--kind string resource Kind
--make make generate if true, run make generate after generating files (default true)
--namespaced resource is namespaced (default true)
--plural string resource irregular plural form
--resource if set, generate the resource without prompting the user (default true)
--version string resource Version
Global Flags:
--plugins strings plugin keys to be used for this subcommand execution
2022/07/19 23:47:18 failed to create API: unable to run post-scaffold tasks of "base.go.kubebuilder.io/v3": exit status 2
Reproducing this issue
Fresh install of go1.18.4 & Make 4.3 try the Quickstart or the tutorial
KubeBuilder (CLI) Version
3.5.0
PROJECT version
3
Plugin versions
No response
Other versions
go1.18.4 linux/amd64 controller-runtime v0.12.1 controller-tools v0.9.0 kubectl v1.24.1 kubernetes v1.24.0 (kind)
Extra Labels
No response
worked for me after apt install gcc
thanks @rgrama , i am also new to go 😅 Would it an idea to put gcc to the prerequisites or is this too basic?
I had the same issue when installed through brew, however if I followed https://sdk.operatorframework.io/docs/installation/ for installing from git release, it works fine. gcc was present for both.
Hi @rgrama,
Could you please check if you install the binary from Kubebuilder releases: https://github.com/kubernetes-sigs/kubebuilder/releases/tag/v3.6.0 (Following the instructions to install: https://book.kubebuilder.io/quick-start.html#installation)
Will you see this issue? It is a problem with the brew formula because the binaries built by Kubebuilder do NOT require GCC. See: https://github.com/kubernetes-sigs/kubebuilder/blob/master/build/.goreleaser.yml#L48
We do not maintain the brew formula so I would recommend open an issue against them. Also, use the binaries and steps to install provided by Kubebuilder instead brew formula.
Closing this one since it is not an issue with what has been kept maintained by the project.
In my case, using Go from go.dev/dl instead of that from linuxbrew solved the problem.
same here, I had installed go with brew. Instead, ive installed it from the release page and worked. https://go.dev/doc/install
running kubebuilder 3.7 and go 1.18.7
worked for me after apt install gcc
This worked for me too!