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

FATA[0020] failed to initialize project: unable to scaffold with "base.go.kubebuilder.io/v3": exit status 2 #5558

Closed
al3xandru opened this issue Feb 18, 2022 · 18 comments
Assignees
Labels
kind/documentation Categorizes issue or PR as related to documentation. triage/support Indicates an issue that is a support question.
Milestone

Comments

@al3xandru
Copy link

First tutorial command fails:

operator-sdk init --domain mypopescu.com --repo github.com/al3xandru/memcached-operator.

The other similar issues suggest an incompatible go version. I made sure the above runs with go 1.16:

go version go1.16.14 darwin/amd64

Output

Writing kustomize manifests for you to edit...
Writing scaffold for you to edit...
Get controller runtime:
$ go get sigs.k8s.io/controller-runtime@v0.11.0
go: downloading github.com/evanphx/json-patch v0.5.2
go: downloading k8s.io/client-go v1.5.2
# sigs.k8s.io/json/internal/golang/encoding/json
/Users/alexandp/go/pkg/mod/sigs.k8s.io/json@v0.0.0-20211020170558-c049b76a60c6/internal/golang/encoding/json/encode.go:1249:12: sf.IsExported undefined (type reflect.StructField has no field or method IsExported)
/Users/alexandp/go/pkg/mod/sigs.k8s.io/json@v0.0.0-20211020170558-c049b76a60c6/internal/golang/encoding/json/encode.go:1255:18: sf.IsExported undefined (type reflect.StructField has no field or method IsExported)
Error: failed to initialize project: unable to scaffold with "base.go.kubebuilder.io/v3": exit status 2
@varshaprasad96
Copy link
Member

@al3xandru you may have to bump the go version to 1.17. kubernetes-sigs/json has StructField.IsExported added which was introduced only in 1.17. Ref: https://pkg.go.dev/reflect#StructField.IsExported

@al3xandru
Copy link
Author

  1. It would be great if the required version of Go was clearly communicated. Different issues are directing users to use 1.16 not 1.17
  2. With Go 1.17, it is the second step of the tutorial that fails.

@jmrodri jmrodri added the kind/documentation Categorizes issue or PR as related to documentation. label Mar 7, 2022
@jmrodri jmrodri added this to the v1.19.0 milestone Mar 7, 2022
@jmrodri
Copy link
Member

jmrodri commented Mar 7, 2022

As of operator-sdk 1.17 we require go 1.17: https://v1-18-x.sdk.operatorframework.io/docs/installation/#prerequisites-1

@jmrodri
Copy link
Member

jmrodri commented Mar 7, 2022

@VenkatRamaraju will double check the tutorial to make sure we're not stating conflicting information

@VenkatRamaraju
Copy link
Contributor

Hey,

I'm able to run the operator-sdk init and create api commands with the latest operator-sdk (1.18) binary and the following go version -

go version go1.17.8 darwin/amd64

My suspicion is that this is some version mismatch. Try the following:

  1. Update the operator-sdk binary to the latest version (i.e., 1.18) and ensure that your operator-sdk CLI invocation is referring to this binary.
  2. Make sure you are using the latest go version, i.e., 1.17.7+
  3. Make sure your GOROOT is set.
  4. When you run operator-sdk version, the go version in that output is the same as the version in the go version command.

If you are still running into this error, let me know what the output of operator-sdk version is.

@tomasfabian
Copy link

Hey,

I'm able to run the operator-sdk init and create api commands with the latest operator-sdk (1.18) binary and the following go version -

go version go1.17.8 darwin/amd64

My suspicion is that this is some version mismatch. Try the following:

  1. Update the operator-sdk binary to the latest version (i.e., 1.18) and ensure that your operator-sdk CLI invocation is referring to this binary.
  2. Make sure you are using the latest go version, i.e., 1.17.7+
  3. Make sure your GOROOT is set.
  4. When you run operator-sdk version, the go version in that output is the same as the version in the go version command.

If you are still running into this error, let me know what the output of operator-sdk version is.

Hi @VenkatRamaraju @al3xandru, I had to run the following command at the beginning, otherwise I received the above mentioned error, too:

sudo -s

Hopefully somehow helpful.

@camilamacedo86
Copy link
Contributor

HI @tomasfabian,

The tool will create/update/read files in the respective directory where you run operator-sdk init. So, if you have no permission to do that an error will be faced.

Then, since you say that execute the command as sudo sorted it out that means you have no permissions in the dir.
My two cents is that run chmod 777 on the dir will allow you to execute the SDK commands without the sudo.

@tomasfabian
Copy link

tomasfabian commented Mar 25, 2022

Hi @camilamacedo86,
now it is of course reasonable that it failed for permission issues, but from the bellow mentioned exception it wasn't so obvious ;)

Error: failed to initialize project: unable to scaffold with "base.go.kubebuilder.io/v3": exit status 2

I was thinking that something else went wrong (go version mismatch etc.). It could be helpful to mention it at least for developers coming from the Windows operating system in the documentation (quick start).

Thanks a lot.

@asmacdo asmacdo modified the milestones: v1.19.0, v1.20.0 Apr 6, 2022
@yimingtech
Copy link

operator-sdk version: "v1.19.0", commit: "728682c347f6335ee2a610e08790a5e1411508f4", kubernetes version: "v1.23", go version: "go1.18", GOOS: "darwin", GOARCH: "amd64" Is an error failed to create API: unable to run post-scaffold tasks of "base.go.kubebuilder.io/v3": exit status 2

@ljavorsk
Copy link

ljavorsk commented Apr 16, 2022

Hi, I've just run into a similar issue...

Environment:
M1 (arm) Mac; Monterey

Operator-sdk version:
operator-sdk version: "v1.19.1", commit: "079d8852ce5b42aa5306a1e33f7ca725ec48d0e3", kubernetes version: "v1.23", go version: "go1.18.1", GOOS: "darwin", GOARCH: "arm64"

Go version:
go version go1.18.1 darwin/arm64

Gcc version:
Apple clang version 13.1.6 (clang-1316.0.21.2) Target: arm64-apple-darwin21.4.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Steps to reproduce on fresh machine:

  1. brew install operator-sdk
  2. mkdir /tmp/test-operator
  3. cd /tmp/test-operator
  4. operator-sdk init --repo <repo>
  5. operator-sdk create api --namespaced=false --group operators --kind MariadbGaleraApp --version v1 --resource --controller

How reproducible:
Always

Result:
.
.
.
/tmp/test-operator/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
bash: line 1: /tmp/test-operator/bin/controller-gen: No such file or directory
make: *** [generate] Error 127
Error: failed to create API: unable to run post-scaffold tasks of "base.go.kubebuilder.io/v3": exit status 2
.
.
.

Could you please help me with this?

I've tried to set the:
export GOROOT=$HOME/go & export PATH=$PATH:$GOROOT/bin
But it didn't solve the issue. Maybe I have to do some additional steps between 4) and 5) steps, but I don't know which.

PS: I've also tried to update both operator-sdk and go packages, but they are the newest stable releases.

@nvvalchev
Copy link

@ljavorsk , I am with the same configuration as yours. Managed to workaround the problem by uninstalling go (v 1.18.1) and installing version 1.17.9.

@ljavorsk
Copy link

@nvvalchev How did you force the version of go to be 1.17? Or did you installed different version of operator-sdk?

Or you didn't used brew and installed it out of source?

@nvvalchev
Copy link

@ljavorsk , I force removed go with brew (as operator-sdk v1.19.1 is dependent on it) and installed go 1.17.9 via brew. Works like charm.

The initial go installation v 1.18.1 was performed by brew as transitive dependency of operator-sdk.

@alejandrojnm
Copy link

I got the same error, I fixed modifying the makefile, search for this variable and replace it with this:

CONTROLLER_GEN=$(GOBIN)/controller-gen
KUSTOMIZE = $(GOBIN)/kustomize
ENVTEST =$(GOBIN)/setup-envtest

because previously every cmd had $(shell pwd)/bin/ in front

@theishshah theishshah modified the milestones: v1.20.0, v1.21.0 Apr 27, 2022
@varshaprasad96 varshaprasad96 added the triage/support Indicates an issue that is a support question. label May 2, 2022
@varshaprasad96 varshaprasad96 added this to the Backlog milestone May 2, 2022
@VenkatRamaraju
Copy link
Contributor

@camilamacedo86 can we close this issue?

@everettraven
Copy link
Contributor

Installs via Homebrew should also be fixed as of: Homebrew/homebrew-core@7e5afcb

@camilamacedo86
Copy link
Contributor

GO 1.18 is still not supported; see: kubernetes-sigs/kubebuilder#2559.
So, we must make go 1.18 be supported in Kubebuilder then we can begin to support here as well.

@camilamacedo86
Copy link
Contributor

camilamacedo86 commented Jul 29, 2022

  • If you fail because you were using go 1.18 and it was not supported. Its supported was added to the latest release
  • If you fail because you are using homebrew and it installs go 1.18 that is fixed as well

Therefore, I think we can close this one. But feel free to raise new issues if you see that you still need help or face issues. So that you can check your specific scenario.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/documentation Categorizes issue or PR as related to documentation. triage/support Indicates an issue that is a support question.
Projects
None yet
Development

No branches or pull requests