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

cmd/go: "An unrecognized flag" is thrown when trying to 'go get' #33616

Closed
Willux opened this issue Aug 13, 2019 · 3 comments

Comments

@Willux
Copy link

commented Aug 13, 2019

What version of Go are you using (go version)?

$ go version
go version go1.12.7 darwin/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

OS: macOS Mojave 10.14.6

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/willux/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/willux/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.7/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.7/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="xcrun"
CXX="xcrun"
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="clang -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/1b/r16kqgrs45jb4fts__bplb7h0000gn/T/go-build497968837=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Ran GO111MODULE=on go get github.com/onsi/ginkgo/ginkgo. I tried go getting other packages, but got the same output.

What did you expect to see?

I expected to get no output and the package to successfully install.

What did you see instead?

The following output was given to me:

go: finding github.com/onsi/ginkgo/ginkgo latest
# runtime/cgo
xcrun: error: unrecognized option: -E
Usage: xcrun [options] <tool name> ... arguments ...

Find and execute the named command line tool from the active developer
directory.

The active developer directory can be set using `xcode-select`, or via the
DEVELOPER_DIR environment variable. See the xcrun and xcode-select manual
pages for more information.

Options:
  -h, --help                  show this help message and exit
  --version                   show the xcrun version
  -v, --verbose               show verbose logging output
  --sdk <sdk name>            find the tool for the given SDK name
  --toolchain <name>          find the tool for the given toolchain
  -l, --log                   show commands to be executed (with --run)
  -f, --find                  only find and print the tool path
  -r, --run                   find and execute the tool (the default behavior)
  -n, --no-cache              do not use the lookup cache
  -k, --kill-cache            invalidate all existing cache entries
  --show-sdk-path             show selected SDK install path
  --show-sdk-version          show selected SDK version
  --show-sdk-build-version    show selected SDK build version
  --show-sdk-platform-path    show selected SDK platform path
  --show-sdk-platform-version show selected SDK platform version
@jayconrod

This comment has been minimized.

Copy link
Contributor

commented Aug 13, 2019

It looks like you have CC and CXX set to xcrun. How are those set? Is that intentional?

The go command uses the C compiler to type check and build cgo code. The program that CC points to must have a command line interface similar to gcc or clang, and it must print errors in the same format.

@Willux

This comment has been minimized.

Copy link
Author

commented Aug 15, 2019

Oh well that's interesting:

$ echo $CC
xcrun clang
$ echo $CXX
xcrun clang++

not sure how it was set though, but I am guessing the xcrun should be omitted?

EDIT:

and wouldn't you know it

export CC=clang
export CXX=clang++

solve the problem. How does that get set. Maybe it's something I installed?

@jayconrod

This comment has been minimized.

Copy link
Contributor

commented Aug 15, 2019

Not sure how those would have been set. Maybe check .profile, .bashrc, or related files?

I'll close this since it seems to be working.

@jayconrod jayconrod closed this Aug 15, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.