Grpc-go: Could not build on macOS for linux amd64 `undefined: unix.GetsockoptLinger`

Created on 27 Jun 2018  Â·  10Comments  Â·  Source: grpc/grpc-go

I tried to build simple packages depends on cloud.google.com/go/spanner/ and got following output.

GOOS=linux GOARCH=amd64 go build  main.go

# google.golang.org/grpc/internal/channelz
../../../google.golang.org/grpc/internal/channelz/types_linux.go:41:15: undefined: unix.GetsockoptLinger
../../../google.golang.org/grpc/internal/channelz/types_linux.go:44:15: undefined: unix.GetsockoptTimeval
../../../google.golang.org/grpc/internal/channelz/types_linux.go:47:15: undefined: unix.GetsockoptTimeval

What version of gRPC are you using?

1.14.0-dev

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

go version go1.10.3 darwin/amd64

What operating system (Linux, Windows, …) and version?

macOS Sierra 10.12.6

Most helpful comment

Could you please update your golang.org/x/sys/unix package by go get -u golang.org/x/sys/unix?
GetsockoptLinger and GetsockoptTimeval are recent additions and your local unix package may not be up to date with the change.

Please kindly close the issue if it works, or let us know if it is still not working. Thanks!

All 10 comments

Could you please update your golang.org/x/sys/unix package by go get -u golang.org/x/sys/unix?
GetsockoptLinger and GetsockoptTimeval are recent additions and your local unix package may not be up to date with the change.

Please kindly close the issue if it works, or let us know if it is still not working. Thanks!

@lyuxuan
go get -u golang.org/x/sys/unix works fine! Thank you for advise. 😄

Hmm, that solution doesn't work for me. Any ideas?

~/go/src/github.com/SamuelMarks/gopherci$ go get -u golang.org/x/sys/unix
~/go/src/github.com/SamuelMarks/gopherci$ go version
go version go1.10.3 linux/amd64
~/go/src/github.com/SamuelMarks/gopherci$ go build
# github.com/SamuelMarks/gopherci/vendor/github.com/fsouza/go-dockerclient/internal/archive
vendor/github.com/fsouza/go-dockerclient/internal/archive/archive.go:74:20: undefined: idtools.IDPair
# github.com/SamuelMarks/gopherci/vendor/google.golang.org/grpc/internal/channelz
vendor/google.golang.org/grpc/internal/channelz/types_linux.go:41:15: undefined: unix.GetsockoptLinger
vendor/google.golang.org/grpc/internal/channelz/types_linux.go:44:15: undefined: unix.GetsockoptTimeval
vendor/google.golang.org/grpc/internal/channelz/types_linux.go:47:15: undefined: unix.GetsockoptTimeval

@SamuelMarks it looks like you will need to update your vendor deps?

My glide.lock has:

- package: golang.org/x/sys
  subpackages:
  - unix

With my glide.yaml having:

- name: golang.org/x/sys
  version: d8e400bc7db4870d786864138af681469693d18c
  subpackages:
  - unix
  - windows

Hmm, manually setting the commit hash to 1c9583448a9c3aa0f9a6a5241bf73c0bd8aafded worked. Weird, I switched the project to glide to try and bump all its dependencies to latest.

Thanks

+1, meet the same problem.

This issue is relevant with glide version control.

setting the commit hash to 1c9583448a9c3aa0f9a6a5241bf73c0bd8aafded worked

Thanks a lot. Manually setting the commit hash also works for me.

I'm getting this when building on an ubuntu machine, and setting the commit hash to 1c9583448a9c3aa0f9a6a5241bf73c0bd8aafded or to the latest commit hash. It works fine when I'm building on my mac

This error means your x/sys/unix library is out of date. Make sure go sees an updated version when building. There are many different possibilities:

  • $GOPATH/src is out of date: go get -u -d google.golang.org/grpc/... will update it.
  • vendor directory is out of date: update your vendored copy of x/sys/unix to a newer verison.
  • Using a version control system like glide: configure it to pull a newer version.

If using go modules (aka "vgo"), then this should not happen unless you've modified our go.mod file, or you have a main go.mod file that pins a specific version of x/sys/unix, or if you are forcing vendoring (via go [build|install|run] -mod vendor).

Thanks for the fast response - After specifying the latest commit hash explicitly in glide.yaml, I forgot to also push the new glide.lock file for the jenkins builder. After doing that it's picking up the latest version and is working now. Thanks!

Was this page helpful?
0 / 5 - 0 ratings