Plugin was built with a different version of package internal/unsafeheader

I am aware of building with mismatched go versions described in:

Problem with go runtime module

I am vendoring nakama-common locally
My go.mod looks like this:

go 1.15

require github.com/heroiclabs/nakama-common v1.10.0

I run go mod vendor

My go version matches: (1.15.5)

$> go version
go version go1.15.5 darwin/amd64

I am building on a remote linux machine using a Dockerfile:

FROM heroiclabs/nakama-pluginbuilder:2.15.0

RUN GO111MODULE=on CGO_ENABLED=1 GOOS=linux go build -v -buildmode=plugin -mod=vendor

When running nakama server 2.15.0, I indeed see "runtime":"go1.15.5"
But also
plugin was built with a different version of package internal/unsafeheader

As far as I know, this error only occurs when the go versions don’t match up somewhere. But it seems this isn’t the case

@pahdo You must use the -trimpath flag when you build your Go code otherwise the Go binaries will include full system path labels inside the runtime metadata which appears as the same error as when you use different versions of the Go runtime. They resolve to the same root problem; the toolchain thinks the Go runtimes bundled in the game server and the plugin are different.

I recommend you use this gist as a guide for how to set up a local development environment based on a Docker multi-stage build:

https://gist.github.com/novabyte/cc6d57022e2d3baa40e98d8fc91dc4c8

Hope it helps.

1 Like

This was exactly it. Thank you so much

1 Like

@pahdo No worries. I’m happy its sorted. There’s some arcane history behind why the Go team added the -trimpath flag to the compiler but in essense its because this issue has never been resolved:

https://github.com/golang/go/issues/17150

However I’m glad they introduced that cmd flag in the meantime. :slight_smile: