Skip to content

Unable to build projects on MacOSX - Error "failed to exec []string{"go", "build", "./..."}: exit status 1" is faced #1733

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

Closed
camilamacedo86 opened this issue Jul 24, 2019 · 8 comments

Comments

@camilamacedo86
Copy link
Contributor

camilamacedo86 commented Jul 24, 2019

Bug Report

Bug

What did you do?

  • Install version 0.9.0
  • Export the env var export GO111MODULE=on
  • Create a new project

What did you expect to see?

  • The process finished without the error.
  • Be able to build the project

What did you see instead? Under which circumstances?

The following error when the project is created.

go: error loading module requirements
Error: failed to exec []string{"go", "build", "./..."}: exit status 1
Usage:
  operator-sdk new <project-name> [flags]

Flags:
      --api-version string          Kubernetes apiVersion and has a format of $GROUP_NAME/$VERSION (e.g app.example.com/v1alpha1) - used with "ansible" or "helm" types
      --dep-manager string          Dependency manager the new project will use (choices: "dep", "modules") (default "modules")
      --generate-playbook           Generate a playbook skeleton. (Only used for --type ansible)
      --git-init                    Initialize the project directory as a git repository (default false)
      --header-file string          Path to file containing headers for generated Go files. Copied to hack/boilerplate.go.txt
      --helm-chart string           Initialize helm operator with existing helm chart (<URL>, <repo>/<name>, or local path)
      --helm-chart-repo string      Chart repository URL for the requested helm chart
      --helm-chart-version string   Specific version of the helm chart (default is latest version)
  -h, --help                        help for new
      --kind string                 Kubernetes CustomResourceDefintion kind. (e.g AppService) - used with "ansible" or "helm" types
      --repo string                 Project repository path for Go operators. Used as the project's Go import path. This must be set if outside of $GOPATH/src with Go modules, and cannot be set if --dep-manager=dep
      --skip-validation             Do not validate the resulting project's structure and dependencies. (Only used for --type go)
      --type string                 Type of operator to initialize (choices: "go", "ansible" or "helm") (default "go")
      --vendor                      Use a vendor directory for dependencies. This flag only applies when --dep-manager=modules (the default)

Global Flags:
      --verbose   Enable verbose logging

camilamacedo@Camilas-MacBook-Pro ~/go/src/github.com/test $ operator-sdk new app-test
FATA[0000] Project (app-test) in (/Users/camilamacedo/go/src/github.com/test/app-test) path already exists. Please use a different project name or delete the existing one 
camilamacedo@Camilas-MacBook-Pro ~/go/src/github.com/test $ cd app-test/
camilamacedo@Camilas-MacBook-Pro ~/go/src/github.com/test/app-test $ ls
build		cmd		deploy		go.mod		pkg		tools.go	version
camilamacedo@Camilas-MacBook-Pro ~/go/src/github.com/test/app-test $ 

Following the error to build.

camilamacedo@Camilas-MacBook-Pro ~/go/src/github.com/test/app-test $ operator-sdk build docker/cmacedo/test-app
/usr/local/go/src/crypto/tls/cipher_suites.go:18:2: unknown import path "golang_org/x/crypto/chacha20poly1305": cannot find module providing package golang_org/x/crypto/chacha20poly1305
/usr/local/go/src/crypto/x509/x509.go:36:2: unknown import path "golang_org/x/crypto/cryptobyte": cannot find module providing package golang_org/x/crypto/cryptobyte
/usr/local/go/src/crypto/x509/x509.go:37:2: unknown import path "golang_org/x/crypto/cryptobyte/asn1": cannot find module providing package golang_org/x/crypto/cryptobyte/asn1
/usr/local/go/src/crypto/tls/key_agreement.go:18:2: unknown import path "golang_org/x/crypto/curve25519": cannot find module providing package golang_org/x/crypto/curve25519
/usr/local/go/src/net/dnsclient.go:11:2: unknown import path "golang_org/x/net/dns/dnsmessage": cannot find module providing package golang_org/x/net/dns/dnsmessage
/usr/local/go/src/net/http/h2_bundle.go:47:2: unknown import path "golang_org/x/net/http/httpguts": cannot find module providing package golang_org/x/net/http/httpguts
/usr/local/go/src/net/http/transport.go:34:2: unknown import path "golang_org/x/net/http/httpproxy": cannot find module providing package golang_org/x/net/http/httpproxy
/usr/local/go/src/net/http/h2_bundle.go:48:2: unknown import path "golang_org/x/net/http2/hpack": cannot find module providing package golang_org/x/net/http2/hpack
/usr/local/go/src/net/http/h2_bundle.go:49:2: unknown import path "golang_org/x/net/idna": cannot find module providing package golang_org/x/net/idna
Error: failed to build operator binary: (failed to exec []string{"go", "build", "-o", "/Users/camilamacedo/go/src/github.com/test/app-test/build/_output/bin/app-test", "-gcflags", "all=-trimpath=/Users/camilamacedo/go/src/github.com/test", "-asmflags", "all=-trimpath=/Users/camilamacedo/go/src/github.com/test", "github.com/test/app-test/cmd/manager"}: exit status 1)
Usage:
  operator-sdk build <image> [flags]

Flags:
      --go-build-args string      Extra Go build arguments as one string such as "-ldflags -X=main.xyz=abc"
  -h, --help                      help for build
      --image-build-args string   Extra image build arguments as one string such as "--build-arg https_proxy=$https_proxy"
      --image-builder string      Tool to build OCI images. One of: [docker, podman, buildah] (default "docker")

Global Flags:
      --verbose   Enable verbose logging

Environment

  • operator-sdk version: v0.9.0, commit: 560208dc998de497bbf59fea1b63426aec430934
  • go version: go version go1.12.7 darwin/amd64
  • SO: Mac 10.14.6
  • ENV VAR's
~/go/src/test $ env | grep GO
GO111MODULE=on
GOROOT=/usr/local/go
GOPATH=/Users/camilamacedo/go

camilamacedo@Camilas-MacBook-Pro ~/go $ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/camilamacedo/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/camilamacedo/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/r_/ym6yn3cd0q3fm5jcgcwvj4z00000gn/T/go-build045556419=/tmp/go-build -gno-record-gcc-switches -fno-common"

```

* Mercurial: 

```
$ hg version
Mercurial Distributed SCM (version 5.0.2)
(see https://mercurial-scm.org for more information)

Copyright (C) 2005-2019 Matt Mackall and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
```
* kubernetes-cli 1.13.4 
@cdc1807
Copy link

cdc1807 commented Jul 24, 2019

I have the same issue. Building from master appears to work for me though

~/gocode/bin/operator-sdk new test-operator
INFO[0000] Creating new Go operator 'test-operator'.
INFO[0000] Created go.mod
INFO[0000] Created tools.go
INFO[0000] Created cmd/manager/main.go
INFO[0000] Created build/Dockerfile
INFO[0000] Created build/bin/entrypoint
INFO[0000] Created build/bin/user_setup
INFO[0000] Created deploy/service_account.yaml
INFO[0000] Created deploy/role.yaml
INFO[0000] Created deploy/role_binding.yaml
INFO[0000] Created deploy/operator.yaml
INFO[0000] Created pkg/apis/apis.go
INFO[0000] Created pkg/controller/controller.go
INFO[0000] Created version/version.go
INFO[0000] Created .gitignore
INFO[0000] Validating project
go: finding github.com/operator-framework/operator-sdk master
go: downloading sigs.k8s.io/controller-runtime v0.1.12
go: downloading github.com/operator-framework/operator-sdk v0.9.1-0.20190724001845-d6e1aba9fa51
go: extracting github.com/operator-framework/operator-sdk v0.9.1-0.20190724001845-d6e1aba9fa51
go: downloading k8s.io/kube-openapi v0.0.0-20190603182131-db7b694dc208
go: extracting k8s.io/kube-openapi v0.0.0-20190603182131-db7b694dc208
go: extracting sigs.k8s.io/controller-runtime v0.1.12
INFO[0021] Project validation successful.
INFO[0021] Project creation complete.

@camilamacedo86 camilamacedo86 changed the title Error to create new project after upgrade to the version 0.9.0 Error "failed to exec []string{"go", "build", "./..."}: exit status 1" is faced when a new project after upgrade to the version 0.9.0 is created Jul 25, 2019
@camilamacedo86
Copy link
Contributor Author

The problem is to build the project as described follows (added the description)

camilamacedo@Camilas-MacBook-Pro ~/go/src/github.com/test/app-test $ operator-sdk build docker/cmacedo/test-app
/usr/local/go/src/crypto/tls/cipher_suites.go:18:2: unknown import path "golang_org/x/crypto/chacha20poly1305": cannot find module providing package golang_org/x/crypto/chacha20poly1305
/usr/local/go/src/crypto/x509/x509.go:36:2: unknown import path "golang_org/x/crypto/cryptobyte": cannot find module providing package golang_org/x/crypto/cryptobyte
/usr/local/go/src/crypto/x509/x509.go:37:2: unknown import path "golang_org/x/crypto/cryptobyte/asn1": cannot find module providing package golang_org/x/crypto/cryptobyte/asn1
/usr/local/go/src/crypto/tls/key_agreement.go:18:2: unknown import path "golang_org/x/crypto/curve25519": cannot find module providing package golang_org/x/crypto/curve25519
/usr/local/go/src/net/dnsclient.go:11:2: unknown import path "golang_org/x/net/dns/dnsmessage": cannot find module providing package golang_org/x/net/dns/dnsmessage
/usr/local/go/src/net/http/h2_bundle.go:47:2: unknown import path "golang_org/x/net/http/httpguts": cannot find module providing package golang_org/x/net/http/httpguts
/usr/local/go/src/net/http/transport.go:34:2: unknown import path "golang_org/x/net/http/httpproxy": cannot find module providing package golang_org/x/net/http/httpproxy
/usr/local/go/src/net/http/h2_bundle.go:48:2: unknown import path "golang_org/x/net/http2/hpack": cannot find module providing package golang_org/x/net/http2/hpack
/usr/local/go/src/net/http/h2_bundle.go:49:2: unknown import path "golang_org/x/net/idna": cannot find module providing package golang_org/x/net/idna
Error: failed to build operator binary: (failed to exec []string{"go", "build", "-o", "/Users/camilamacedo/go/src/github.com/test/app-test/build/_output/bin/app-test", "-gcflags", "all=-trimpath=/Users/camilamacedo/go/src/github.com/test", "-asmflags", "all=-trimpath=/Users/camilamacedo/go/src/github.com/test", "github.com/test/app-test/cmd/manager"}: exit status 1)
Usage:
  operator-sdk build <image> [flags]

Flags:
      --go-build-args string      Extra Go build arguments as one string such as "-ldflags -X=main.xyz=abc"
  -h, --help                      help for build
      --image-build-args string   Extra image build arguments as one string such as "--build-arg https_proxy=$https_proxy"
      --image-builder string      Tool to build OCI images. One of: [docker, podman, buildah] (default "docker")

Global Flags:
      --verbose   Enable verbose logging

@camilamacedo86 camilamacedo86 changed the title Error "failed to exec []string{"go", "build", "./..."}: exit status 1" is faced when a new project after upgrade to the version 0.9.0 is created Error "failed to exec []string{"go", "build", "./..."}: exit status 1" is faced when a new project after upgrade to the version 0.9.0 is created and when we try to build the project Jul 25, 2019
@camilamacedo86 camilamacedo86 changed the title Error "failed to exec []string{"go", "build", "./..."}: exit status 1" is faced when a new project after upgrade to the version 0.9.0 is created and when we try to build the project Unable to build projects on MacOSX - Error "failed to exec []string{"go", "build", "./..."}: exit status 1" is faced Aug 4, 2019
@camilamacedo86
Copy link
Contributor Author

Hi @lilic, @johananl, @hasbro17 have you any idea?
I am still unable to use the operator-sdk 0.9.0 with a Mac OS X.

@lilic
Copy link
Member

lilic commented Aug 4, 2019

@camilamacedo86 how did you install it?

I just did a fresh install using homebrew on a MAC and it works fine for me. Can you run go build cmd/manager/main.go? Did you run go mod vendor, it seems like it might be a problem with your deps.

Below is my output and it worked correctly:

○ go version
go version go1.12.7 darwin/amd64

○ env | grep GO
GOPATH=/Users/lili/projects/go

○ operator-sdk version
operator-sdk version: v0.9.0, commit: 560208dc998de497bbf59fea1b63426aec430934

○ operator-sdk build quay.io/example/lili-operator:123
INFO[0050] Building OCI image quay.io/example/lili-operator:123
Sending build context to Docker daemon  144.9MB
Step 1/4 : FROM alpine:3.8
3.8: Pulling from library/alpine
c87736221ed0: Pull complete
Digest: sha256:04696b491e0cc3c58a75bace8941c14c924b9f313b03ce5029ebbc040ed9dcd9
Status: Downloaded newer image for alpine:3.8
 ---> dac705114996
Step 2/4 : RUN apk upgrade --update --no-cache
 ---> Running in 24707d62b4d8
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
OK: 4 MiB in 13 packages
Removing intermediate container 24707d62b4d8
 ---> 72790a31917c
Step 3/4 : USER nobody
 ---> Running in 753b0e944c43
Removing intermediate container 753b0e944c43
 ---> 03556639883c
Step 4/4 : ADD build/_output/bin/bla-operator /usr/local/bin/bla-operator
 ---> fea74f949f53
Successfully built fea74f949f53
Successfully tagged quay.io/example/lili-operator:123
INFO[0083] Operator build complete.

@camilamacedo86
Copy link
Contributor Author

Hi @lilic tks.

Really thanks for your support here. I found the problem. It was the GOROOT.
It was GOROOT="/usr/local/go" and it was solved when I added the path of its installation from homebrew GOROOT="/usr/local/Cellar/go/1.12.7/libexec"

c/c @cdc1807

@xlucas
Copy link

xlucas commented Aug 7, 2019

I can confirm the issue is there with 0.9.0 but not with 0.8.2 even if $GOROOT is unchanged between invocations of operator-sdk new <project> so I think it should be reopened.

@camilamacedo86
Copy link
Contributor Author

Hi @xlucas,

Did you check your env vars? Have you more than one go env? Note that I could fix my env and now all is working with success.

@xlucas
Copy link

xlucas commented Aug 7, 2019

Hi @camilamacedo86. Yes I did check them, nothing sounds wrong to me:

➜ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/xavier.lucas/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/xavier.lucas/Workspace/code/go"
GOPROXY=""
GORACE=""
GOROOT="/Users/xavier.lucas/.asdf/installs/golang/1.12/go"
GOTMPDIR=""
GOTOOLDIR="/Users/xavier.lucas/.asdf/installs/golang/1.12/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/l3/z58chgb577v9wtq5pn4xt0rr0000gn/T/go-build155659366=/tmp/go-build -gno-record-gcc-switches -fno-common"

I'm using several go envs thanks to a version manager (asdf) and I switch between them on a per-project basis. However I don't think it's relevant here since these versions are not mixed up by manual installations or anything and my tests were done on the same version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants