Go: plugin was built with a different version of package path/filepath

WITHOUT DOCKER

Plugin was built and runs with error on my linux server and the nakama binary runs on this linux server as well.


  1. Nakama version: 3.17.1, Linux binary
  2. Server Framework Runtime language: Go
  3. OS: Ubuntu 20.04.4 LTS
  4. Go version: go1.20.8 linux/amd64

Setup:

$ go mod init mm-server
$ go mod tidy
$ go mod vendor
$ go build -buildmode=plugin -trimpath -o /opt/nakama/data/modules/matchmaker.so

go.mod

module mm-server

go 1.20

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

require google.golang.org/protobuf v1.31.0 // indirect

vendor/modules.txt

# github.com/heroiclabs/nakama-common v1.28.1
## explicit; go 1.19
github.com/heroiclabs/nakama-common/api
github.com/heroiclabs/nakama-common/rtapi
github.com/heroiclabs/nakama-common/runtime
# google.golang.org/protobuf v1.31.0
## explicit; go 1.11
google.golang.org/protobuf/encoding/prototext
google.golang.org/protobuf/encoding/protowire
google.golang.org/protobuf/internal/descfmt
google.golang.org/protobuf/internal/descopts
google.golang.org/protobuf/internal/detrand
google.golang.org/protobuf/internal/encoding/defval
google.golang.org/protobuf/internal/encoding/messageset
google.golang.org/protobuf/internal/encoding/tag
google.golang.org/protobuf/internal/encoding/text
google.golang.org/protobuf/internal/errors
google.golang.org/protobuf/internal/filedesc
google.golang.org/protobuf/internal/filetype
google.golang.org/protobuf/internal/flags
google.golang.org/protobuf/internal/genid
google.golang.org/protobuf/internal/impl
google.golang.org/protobuf/internal/order
google.golang.org/protobuf/internal/pragma
google.golang.org/protobuf/internal/set
google.golang.org/protobuf/internal/strs
google.golang.org/protobuf/internal/version
google.golang.org/protobuf/proto
google.golang.org/protobuf/reflect/protoreflect
google.golang.org/protobuf/reflect/protoregistry
google.golang.org/protobuf/runtime/protoiface
google.golang.org/protobuf/runtime/protoimpl
google.golang.org/protobuf/types/known/timestamppb
google.golang.org/protobuf/types/known/wrapperspb
$ nakama --database.address ... --runtime.path /opt/nakama/data/modules/

{"level":"info","ts":"2023-09-14T10:20:20.932Z","caller":"v3/main.go:105","msg":"Node","name":"nakama","version":"3.17.1+258a7f35","runtime":"go1.20.6","cpu":1,"proc":1}
{"level":"info","ts":"2023-09-14T10:20:20.932Z","caller":"v3/main.go:106","msg":"Data directory","path":"/home/user/data"}
{"level":"info","ts":"2023-09-14T10:20:20.932Z","caller":"v3/main.go:117","msg":"Database connections","dsns":["user:xxxxx@127.0.0.1:5432"]}
{"level":"info","ts":"2023-09-14T10:20:20.948Z","caller":"v3/main.go:123","msg":"Database information","version":"PostgreSQL 12.16 (Ubuntu 12.16-0ubuntu0.20.04.1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0, 64-bit"}
{"level":"info","ts":"2023-09-14T10:20:20.957Z","caller":"server/leaderboard_rank_cache.go:120","msg":"Initializing leaderboard rank cache"}
{"level":"info","ts":"2023-09-14T10:20:20.957Z","caller":"server/runtime.go:628","msg":"Initialising runtime","path":"/opt/nakama/data/modules/"}
{"level":"info","ts":"2023-09-14T10:20:20.958Z","caller":"server/runtime.go:635","msg":"Initialising runtime event queue processor"}
{"level":"info","ts":"2023-09-14T10:20:20.958Z","caller":"server/runtime.go:637","msg":"Runtime event queue processor started","size":65536,"workers":8}
{"level":"warn","ts":"2023-09-14T10:20:20.958Z","caller":"satori/satori.go:64","msg":"Satori configuration invalid: api_key_name not set, api_key not set, signing_key not set."}
{"level":"info","ts":"2023-09-14T10:20:20.958Z","caller":"server/runtime_go.go:2672","msg":"Initialising Go runtime provider","path":"/opt/nakama/data/modules/"}
{"level":"info","ts":"2023-09-14T10:20:20.958Z","caller":"server/leaderboard_rank_cache.go:181","msg":"Leaderboard rank cache initialization completed successfully","cached":[],"skipped":[],"duration":"1.376457ms"}
{"level":"error","ts":"2023-09-14T10:20:20.966Z","caller":"server/runtime_go.go:2768","msg":"Could not open Go module","path":"/opt/nakama/data/modules/matchmaker.so","error":"plugin.Open(\"/opt/nakama/data/modules/matchmaker\"): plugin was built with a different version of package path/filepath"}
{"level":"error","ts":"2023-09-14T10:20:20.966Z","caller":"server/runtime.go:643","msg":"Error initialising Go runtime provider","error":"plugin.Open(\"/opt/nakama/data/modules/matchmaker\"): plugin was built with a different version of package path/filepath"}
{"level":"fatal","ts":"2023-09-14T10:20:20.966Z","caller":"v3/main.go:156","msg":"Failed initializing runtime modules","error":"plugin.Open(\"/opt/nakama/data/modules/matchmaker\"): plugin was built with a different version of package path/filepath"}

Hello @kingsley, please have a look at our dependency pinning guide.

So the issue was causes by Go Runtime Version Mismatch

Ensure you compile your Go server runtime module with the same version of Go as the Nakama binary was compiled with.

The Nakama binary I was using was compiled with Go version 1.20.6, and I compiled my runtime module with Go version 1.20.8. Just use the same Go version to build the plugin should resolve the issue.