I am facing issues with the dependency pinning after adding Firebase to my golang project with Nakama.
May you guys know which configuration I should use?
Thanks,
Daniele
I am facing issues with the dependency pinning after adding Firebase to my golang project with Nakama.
May you guys know which configuration I should use?
Thanks,
Daniele
Hello @ilmalte, what version of Nakama are you running and what does your plugin go.mod
file look like?
Thanks for the quick reply @sesposito.
For context, I wanted to add FCM for push notifications so I added:
go get firebase.google.com/go/v4/messaging
go get firebase.google.com/go/v4
go get google.golang.org/api/option
This is the error I get when I run the docker compose up
.
nakama_backend | {"level":"error","ts":"2024-06-05T12:51:57.456Z","caller":"server/runtime_go.go:2820","msg":"Could not open Go module","path":"/nakama/data/modules/backend.so","error":"plugin.Open(\"/nakama/data/modules/backend\"): plugin was built with a different version of package google.golang.org/protobuf/internal/pragma"}
nakama_backend | {"level":"error","ts":"2024-06-05T12:51:57.456Z","caller":"server/runtime.go:647","msg":"Error initialising Go runtime provider","error":"plugin.Open(\"/nakama/data/modules/backend\"): plugin was built with a different version of package google.golang.org/protobuf/internal/pragma"}
nakama_backend | {"level":"fatal","ts":"2024-06-05T12:51:57.456Z","caller":"main.go:166","msg":"Failed initializing runtime modules","error":"plugin.Open(\"/nakama/data/modules/backend\"): plugin was built with a different version of package google.golang.org/protobuf/internal/pragma"}
I am currently using 3.20.0 but I also tried to change the version to 3.21.1 and I still get the error.
FROM heroiclabs/nakama-pluginbuilder:3.20.0 as builder
ENV GO111MODULE on
ENV CGO_ENABLED 1
WORKDIR /backend
COPY . .
# COPY go.mod .
# COPY *.go .
# COPY vendor/ vendor/
RUN go build --trimpath --buildmode=plugin -o ./backend.so
FROM heroiclabs/nakama:3.20.0
COPY --from=builder /backend/backend.so /nakama/data/modules
COPY local.yml /nakama/data
This was my (working) go.mod
before the packages.
module backend
go 1.21
require github.com/minio/minio-go/v7 v7.0.67
require github.com/google/go-querystring v1.1.0 // indirect
require (
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/google/uuid v1.5.0 // indirect
github.com/heroiclabs/nakama-common v1.30.1 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.4 // indirect
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
github.com/mailersend/mailersend-go v1.5.1
github.com/minio/md5-simd v1.1.2 // indirect
github.com/minio/sha256-simd v1.0.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/rs/xid v1.5.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
)
This is my current (not working) go.mod
.
module backend
go 1.21
require github.com/minio/minio-go/v7 v7.0.67
require (
cloud.google.com/go v0.114.0 // indirect
cloud.google.com/go/auth v0.5.1 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect
cloud.google.com/go/compute v1.27.0 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
cloud.google.com/go/firestore v1.15.0 // indirect
cloud.google.com/go/iam v1.1.8 // indirect
cloud.google.com/go/longrunning v0.5.7 // indirect
cloud.google.com/go/storage v1.40.0 // indirect
firebase.google.com/go/v4 v4.14.1 // indirect
github.com/MicahParks/keyfunc v1.9.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.4 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/api v0.183.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/appengine/v2 v2.0.2 // indirect
google.golang.org/genproto v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240521202816-d264139d666e // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/grpc v1.64.0 // indirect
)
require (
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/heroiclabs/nakama-common v1.30.1 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.4 // indirect
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
github.com/mailersend/mailersend-go v1.5.1
github.com/minio/md5-simd v1.1.2 // indirect
github.com/minio/sha256-simd v1.0.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/rs/xid v1.5.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
)
This is my very first golang project and I am struggling a bit to fix this issue
The following should work using Nakama 3.21.1
and considering the dependencies you have in your files above:
go.mod:
go 1.21
require (
firebase.google.com/go/v4 v4.13.0
github.com/heroiclabs/nakama-common v1.31.0
github.com/minio/minio-go/v7 v7.0.67
golang.org/x/oauth2 v0.15.0
google.golang.org/genproto/googleapis/api v0.0.0-20231212172506-995d672761c0
google.golang.org/genproto/googleapis/rpc v0.0.0-20231211222908-989df2bf70f3
google.golang.org/grpc v1.60.0
google.golang.org/protobuf v1.31.0
)
You should also add the following to your plugin main.go
imports:
import (
_ "firebase.google.com/go/v4"
_ "github.com/minio/minio-go/v7"
_ "golang.org/x/oauth2"
_ "google.golang.org/genproto/googleapis/api"
_ "google.golang.org/genproto/googleapis/rpc/status"
_ "google.golang.org/grpc"
)
Do not forget to run go mod tidy && go mod vendor
after you apply these changes.
This one was a bit hairy, we should be releasing Nakama 3.22.0 soon, at which point we should bump all of its dependencies which may require some changes here if you upgrade.
Given this example and following our dependency pinning guide, hopefully you can work through it if needed.
Hope this helps,
Best.
I’ve just tried your suggestions but I am still a bit lost.
Before running go mod tidy && go mod vendor
I also deleted the vendor folder to be sure the command was working as expected.
Docker file with version 3.21.1
.
FROM heroiclabs/nakama-pluginbuilder:3.21.1 as builder
ENV GO111MODULE on
ENV CGO_ENABLED 1
WORKDIR /backend
COPY . .
RUN go build --trimpath --buildmode=plugin -o ./backend.so
FROM heroiclabs/nakama:3.21.1
COPY --from=builder /backend/backend.so /nakama/data/modules
COPY local.yml /nakama/data
The main.go
with the new imports.
package main
import (
"context"
"database/sql"
"time"
_ "firebase.google.com/go/v4"
_ "github.com/minio/minio-go/v7"
_ "golang.org/x/oauth2"
_ "google.golang.org/genproto/googleapis/api"
_ "google.golang.org/genproto/googleapis/rpc/status"
_ "google.golang.org/grpc"
"github.com/heroiclabs/nakama-common/rtapi"
"github.com/heroiclabs/nakama-common/runtime"
... more imports for my RPC, Hooks, utils, etc methods
)
The go.mod
file updated.
module backend
go 1.21
require (
firebase.google.com/go/v4 v4.13.0
github.com/heroiclabs/nakama-common v1.31.0
github.com/minio/minio-go/v7 v7.0.67
golang.org/x/oauth2 v0.20.0
google.golang.org/api v0.180.0
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157
google.golang.org/grpc v1.64.0
)
The errors I still face when running docker compose build --no-cache && docker compose up
.
nakama_backend | {"level":"error","ts":"2024-06-06T19:08:21.481Z","caller":"server/runtime_go.go:2820","msg":"Could not open Go module","path":"/nakama/data/modules/backend.so","error":"plugin.Open(\"/nakama/data/modules/backend\"): plugin was built with a different version of package google.golang.org/protobuf/internal/pragma"}
nakama_backend | {"level":"error","ts":"2024-06-06T19:08:21.481Z","caller":"server/runtime.go:647","msg":"Error initialising Go runtime provider","error":"plugin.Open(\"/nakama/data/modules/backend\"): plugin was built with a different version of package google.golang.org/protobuf/internal/pragma"}
nakama_backend | {"level":"fatal","ts":"2024-06-06T19:08:21.481Z","caller":"main.go:166","msg":"Failed initializing runtime modules","error":"plugin.Open(\"/nakama/data/modules/backend\"): plugin was built with a different version of package google.golang.org/protobuf/internal/pragma"}
May am I missing something?
Something wrong with my environment perhaps?
I cannot imagine this being relevant but in case it’s needed:
go version go1.21.0 linux/amd64
For now, thank you very much for your help.
I don’t understand why your latest go.mod
has different versions than the one I provided, if you use that it should have the correct dependencies pinned.
I suggest you delete your go.mod
and go.sum
and paste exactly what I gave you in a new go.mod
, then retry to run go mod tidy && go mod vendor
.
If the go.mod
entries change versions again something’s incorrect.
Best.
Deleting the go.mod
and go.sum
helped fixing the situation.
Nakama now starts correctly, thank you very much!
nakama_backend | {"level":"info","ts":"2024-06-06T20:05:49.494Z","caller":"main.go:113","msg":"Nakama starting"}
nakama_backend | {"level":"info","ts":"2024-06-06T20:05:49.494Z","caller":"main.go:114","msg":"Node","name":"nakama1","version":"3.21.1+cd82b6c5","runtime":"go1.21.6","cpu":8,"proc":8}
nakama_backend | {"level":"info","ts":"2024-06-06T20:05:49.494Z","caller":"main.go:115","msg":"Data directory","path":"/nakama/data"}
After the go mod tidy && go mod vendor
it still differs from yours.
module backend
go 1.21
require (
firebase.google.com/go/v4 v4.13.0
github.com/heroiclabs/nakama-common v1.31.0
github.com/mailersend/mailersend-go v1.5.1
github.com/minio/minio-go/v7 v7.0.67
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8
golang.org/x/oauth2 v0.15.0
google.golang.org/api v0.149.0
google.golang.org/genproto/googleapis/api v0.0.0-20231212172506-995d672761c0
google.golang.org/genproto/googleapis/rpc v0.0.0-20231211222908-989df2bf70f3
google.golang.org/grpc v1.60.0
)
But nakama now starts so I would say the issue as been solved
Thank you very much for your time Simon.
Best.