Closed jsarkar closed 4 years ago
/assign @camilamacedo86
Hi @jsarkar,
As we spoke in the slack I am unable to reproduce the issue using the version informed. So, could you please: a) could you let us know if you are using it inside or outside of your $GOPATH?
Note If you are not familiarised with Go, I'd recommend you perform the steps inside of your $GOPATH in order to keep the simplicity. for further information see the notes in https://book.kubebuilder.io/quick-start.html
mkdir $GOPATH/src/example
cd $GOPATH/src/example
kubebuilder init --domain my.domain
b) Could you please provide your Go env? (Output of the command $go env
)
c) Could you please try to verify your go installation first by following these steps? Is it working for you?
Also, it really shows a Go setup issue. See: https://forum.golangbridge.org/t/cgo-build-error-help-me/16077/3
@camilamacedo86 I have tested inside and outside GOPATH. However the below snippet shows , I am trying initialize kubebuilder inside GOPATH
joysarkar@jsarkar:~/projects/gocode/src/example$ direnv allow
direnv: loading ~/projects/gocode/src/example/.envrc
direnv: export +GOPATH ~PATH
joysarkar@jsarkar:~/projects/gocode/src/example$ cd $GOPATH/src/example
joysarkar@jsarkar:~/projects/gocode/src/example$ kubebuilder version
Version: version.Version{KubeBuilderVersion:"2.3.1", KubernetesVendor:"1.16.4", GitCommit:"8b53abeb4280186e494b726edf8f54ca7aa64a49", BuildDate:"2020-03-26T16:42:00Z", GoOs:"unknown", GoArch:"unknown"}
joysarkar@jsarkar:~/projects/gocode/src/example$ kubebuilder init --domain my.domain
Writing scaffold for you to edit...
Get controller runtime:
$ go get sigs.k8s.io/controller-runtime@v0.5.0
Update go.mod:
$ go mod tidy
Running make:
$ make
go: creating new go.mod: module tmp
go: finding sigs.k8s.io v0.2.5
go: finding sigs.k8s.io/controller-tools/cmd/controller-gen v0.2.5
go: finding sigs.k8s.io/controller-tools/cmd v0.2.5
/home/joysarkar/projects/gocode/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
go fmt ./...
go vet ./...
# runtime/cgo
_cgo_export.c:3:20: fatal error: stdlib.h: No such file or directory
compilation terminated.
make: *** [Makefile:51: vet] Error 2
2020/07/30 08:48:53 failed to initialize project: exit status 2
Here is my goenv
o/p
joysarkar@jsarkar:~/projects/gocode/src/example$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/joysarkar/.cache/go-build"
GOENV="/home/joysarkar/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/joysarkar/projects/gocode"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/joysarkar/bin/go-1.13.14"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/joysarkar/bin/go-1.13.14/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/joysarkar/projects/gocode/src/example/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build764099610=/tmp/go-build -gno-record-gcc-switches"
I have tested my GO installtion also
joysarkar@jsarkar:~/projects/gocode/src/example$ vi hello.go
joysarkar@jsarkar:~/projects/gocode/src/example$ go build hello.go
joysarkar@jsarkar:~/projects/gocode/src/example$ ./hello
hello, world
My laptop is not arm nither I am trying cross-compile CGO. So really not sure what to follow the issue link you have refered.
I have noticed some how my default CGO config is enabled (CGO_ENABLED="1"). I have disabled and now I am able to initialize the project. I am good here and will close the issue
Hi @jsarkar, Really thank you for share and let us know
I am trying use the latest release of kubebuilder (2.3.1) and initialize a project by running kubebuilder init --domain my.domain
kubebuilder init --domain my.domain Writing scaffold for you to edit... Get controller runtime: $ go get sigs.k8s.io/controller-runtime@v0.5.0 Update go.mod: $ go mod tidy Running make: $ make go: creating new go.mod: module tmp go: finding sigs.k8s.io v0.2.5 go: finding sigs.k8s.io/controller-tools/cmd v0.2.5 go: finding sigs.k8s.io/controller-tools/cmd/controller-gen v0.2.5 /home/joysarkar/go/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..." go fmt ./... go vet ./...
runtime/cgo
_cgo_export.c:3:20: fatal error: stdlib.h: No such file or directory compilation terminated. make: *** [Makefile:51: vet] Error 2 2020/07/28 21:59:27 failed to initialize project: exit status 2
P roject initialized successfully
What versions of software are you using? Specifically, the following are often useful: kubebuilder version Version: version.Version{KubeBuilderVersion:"2.3.1", KubernetesVendor:"1.16.4", GitCommit:"8b53abeb4280186e494b726edf8f54ca7aa64a49", BuildDate:"2020-03-26T16:42:00Z", GoOs:"unknown", GoArch:"unknown"}
kubebuilder version
) and scaffolding version (check yourPROJECT
file) 2.3.1go.mod
file)kubectl version
against your API server)/kind bug