FATA[0009] failed to create API: unable to run post-scaffold tasks of “base.go.kubebuilder.io/v3”: exit status 2

This blog post is about how you could save time, when you are starting to setup your development environment for a GO operator with the Operator SDK on a macOS, in combination with Visual Studio Code.

Please take also a look in the blog post make: *** [generate] Error 127, which is currently related to that topic.

Maybe you started already with GO and you have installed GO with the normal GO installation for macOS. I mean you didn’t use the brew package manager for the first GO installation and you maybe also have configured environment variables like the GOPATH and GOROOT.


export GOPATH=/usr/local/go
export GOROOT=$GOPATH/bin

All works fine for you. After you have installed the Operator SDK using brew you maybe got the error I mentioned in the headline, when you are going to create an API for your operator.

Example steps to create an operator API using the Operator SDK:

  • Init
operator-sdk init --domain example.net --repo github.com/yourproject/youroperator

  • Create API
operator-sdk create api --group yourgroup --version v1alpha1 --kind yourcrd --resource --controller

Again the error:

FATA[0009] failed to create API: unable to run post-scaffold tasks of "base.go.kubebuilder.io/v3": exit status 2

When you start to find solutions for that error on Google, the error message guides you to an access rights problem.

In my case I figured out that the root cause for the error is that the Operator SDK installation was done with brew, which installed the needed GO version for the Operator SDK. That could create the situation that you have two versions of GO installed, which do have different configurations, which can create an access rights problem.

The simple solution in that situation is:

Just clean your GO and Operator SDK installation and only use brew to install the Operator SDK, which will install GO for you.

These are the steps which maybe can help you in that situation.

Step 1: Ensure you have a clean system:

brew uninstall operator-sdk
brew uninstall go
sudo rm -rf /usr/local/Cellar/go
sudo rm -rf /usr/local/go
sudo rm -rf /Users/YOUR_USER/go

Step 2: Install the Operator SDK using brew

Again: That will install the Operator SDK and the related GO working version!

brew install operator-sdk

Step 3: Verify the installed packages

brew list | grep "go"
brew list | grep "operator-sdk"

Step 4: Ensure there is no remaining cache from your previous installation

sudo go clean -cache

Step 5: Install/reinstall the GO extension to Visual Studio Code

Now, you should be ready to go!

Note: By the way if you are new to GO, you should just install GO and use it, and don’t customize any environment variables if you don’t exactly know what you are doing ;-).

I hope this was useful for you and let’s see what’s next?



#operator, #brew, #go, #operatorsdk, #macos, #operatorlearningjourney

4 thoughts on “FATA[0009] failed to create API: unable to run post-scaffold tasks of “base.go.kubebuilder.io/v3”: exit status 2

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.