# Failed initializing runtime modules: plugin was built with a different version of package google.golang.org/protobuf/internal/pragma

**URL:** <https://forum.heroiclabs.com/t/failed-initializing-runtime-modules-plugin-was-built-with-a-different-version-of-package-google-golang-org-protobuf-internal-pragma/3265>\
**Category:** Local Setup\
**Tags:** getting-started\
**Created:** [November 16, 2022, 11:49pm UTC](https://forum.heroiclabs.com/t/failed-initializing-runtime-modules-plugin-was-built-with-a-different-version-of-package-google-golang-org-protobuf-internal-pragma/3265 "2022-11-16T23:49:21Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![technicallyty](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/technicallyty/32/1435_2.png) [@technicallyty](https://forum.heroiclabs.com/u/technicallyty)\
**Post date:** [November 16, 2022, 11:49pm UTC](https://forum.heroiclabs.com/t/failed-initializing-runtime-modules-plugin-was-built-with-a-different-version-of-package-google-golang-org-protobuf-internal-pragma/3265/1 "2022-11-16T23:49:21Z")

</div>

Was trying to follow video tutorial here: [Nakama: Go Runtime | Heroic Labs Documentation](https://heroiclabs.com/docs/nakama/server-framework/go-runtime/)

Unfortunately, cannot get it to run. see logs below.

1. Versions: Nakama 3.14.0, Docker, require [GitHub - heroiclabs/nakama-common: The runtime framework for Nakama server.](http://github.com/heroiclabs/nakama-common) v1.25.0
2. Server Framework Runtime language: Go 1.19

Logs:

```auto
{"level":"error","ts":"2022-11-16T23:39:10.259Z","caller":"server/runtime_go.go:2494","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"}
{"level":"error","ts":"2022-11-16T23:39:10.260Z","caller":"server/runtime.go:586","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"}
{"level":"fatal","ts":"2022-11-16T23:39:10.260Z","caller":"main.go:146","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"}

```

Dockerfile:

```auto
FROM heroiclabs/nakama-pluginbuilder:3.3.0 AS go-builder

ENV GO111MODULE on
ENV CGO_ENABLED 1

WORKDIR /backend

COPY go.mod .
COPY main.go .
COPY vendor/ vendor/

RUN go build --trimpath --mod=vendor --buildmode=plugin -o ./backend.so

FROM registry.heroiclabs.com/heroiclabs/nakama:3.14.0

COPY --from=go-builder /backend/backend.so /nakama/data/modules/
COPY local.yml /nakama/data/

```

go.mod file:

```auto
module github.com/technicallyty/nakama-demo

go 1.19

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

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

```

docker-compose.yml:

```auto
version: '3'
services:
  postgres:
    command: postgres -c shared_preload_libraries=pg_stat_statements -c pg_stat_statements.track=all
    container_name: backend_postgres
    environment:
      - POSTGRES_DB=nakama
      - POSTGRES_PASSWORD=localdb
    expose:
      - "8080"
      - "5432"
    image: postgres:12.2-alpine
    ports:
      - "5432:5432"
      - "8080:8080"
    volumes:
      - data:/var/lib/postgresql/data

  nakama:
    build: .
    container_name: backend
    depends_on:
      - postgres
    entrypoint:
      - "/bin/sh"
      - "-ecx"
      - >
        /nakama/nakama migrate up --database.address postgres:localdb@postgres:5432/nakama?sslmode=disable &&
        exec /nakama/nakama --config /nakama/data/local.yml --database.address postgres:localdb@postgres:5432/nakama?sslmode=disable
    expose:
      - "7349"
      - "7350"
      - "7351"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:7350/"]
      interval: 10s
      timeout: 5s
      retries: 5
    links:
      - "postgres:db"
    ports:
      - "7349:7349"
      - "7350:7350"
      - "7351:7351"
    restart: unless-stopped

volumes:
  data:

```

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [November 17, 2022, 10:18am UTC](https://forum.heroiclabs.com/t/failed-initializing-runtime-modules-plugin-was-built-with-a-different-version-of-package-google-golang-org-protobuf-internal-pragma/3265/2 "2022-11-17T10:18:25Z")

</div>

Hello @technicallyty, this looks like a dependency pinning issue, have you tried to follow our [related guide](https://heroiclabs.com/docs/nakama/server-framework/go-runtime/go-dependencies/)?

---

<div class="post-metadata">

**Author:** ![technicallyty](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/technicallyty/32/1435_2.png) [@technicallyty](https://forum.heroiclabs.com/u/technicallyty)\
**Post date:** [November 17, 2022, 5:53pm UTC](https://forum.heroiclabs.com/t/failed-initializing-runtime-modules-plugin-was-built-with-a-different-version-of-package-google-golang-org-protobuf-internal-pragma/3265/3 "2022-11-17T17:53:22Z")

</div>

I did look at that, but im not sure how to apply that solution to my problem.

For example, the error is thrown from an internal package from the protobuf import, so i can’t import it as a direct dependency (i.e. using `_` “[pragma package - google.golang.org/protobuf/internal/pragma - Go Packages](http://google.golang.org/protobuf/internal/pragma)”).

I also can’t just import this: `_` “[protobuf module - google.golang.org/protobuf - Go Packages](http://google.golang.org/protobuf)” otherwise i get this error:  
`Build constraints exclude all the Go files in '/Users/technicallyty/go/pkg/mod/google.golang.org/protobuf@v1.28.1'`

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [November 17, 2022, 6:20pm UTC](https://forum.heroiclabs.com/t/failed-initializing-runtime-modules-plugin-was-built-with-a-different-version-of-package-google-golang-org-protobuf-internal-pragma/3265/4 "2022-11-17T18:20:08Z")

</div>

I’ve just noticed that in the Dockerfile:  
`FROM heroiclabs/nakama-pluginbuilder:3.3.0 AS go-builder`  
should match the Nakama version, so it should be instead  
`FROM heroiclabs/nakama-pluginbuilder:3.14.0 AS go-builder`

Can you please replace and see if this resolves the issue?

/cc @gabriel

---

<div class="post-metadata">

**Author:** ![technicallyty](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/technicallyty/32/1435_2.png) [@technicallyty](https://forum.heroiclabs.com/u/technicallyty)\
**Post date:** [November 17, 2022, 7:16pm UTC](https://forum.heroiclabs.com/t/failed-initializing-runtime-modules-plugin-was-built-with-a-different-version-of-package-google-golang-org-protobuf-internal-pragma/3265/5 "2022-11-17T19:16:12Z")

</div>

ok that gets rid of the other error, but now im getting this:

```auto
{"level":"fatal","ts":"2022-11-17T19:13:50.085Z","caller":"server/runtime_go.go:2628","msg":"Error reading InitModule function in Go module","name":"backend"}

```

here’s the code that sets up the module:

```go
package main

import (
	"context"
	"database/sql"
	"encoding/json"
	"time"

	"github.com/heroiclabs/nakama-common/runtime"
)

func InitModule(ctx context.Context, logger runtime.Logger, db *sql.DB, iz runtime.Initializer) error {
	initStart := time.Now()

	if err := iz.RegisterRpc("health", RpcHealthCheck); err != nil {
		return err
	}

	logger.Info("module loaded in %ms", time.Since(initStart).Milliseconds())
	return nil
}

type HealthCheckResponse struct {
	Success bool `json:"success"`
}

func RpcHealthCheck(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, payload string) (string, error) {
	logger.Debug("Healthcheck RPC called")
	response := &HealthCheckResponse{Success: true}

	out, err := json.Marshal(response)
	if err != nil {
		logger.Error("cannot marshal response: %w", err)
		return "", runtime.NewError("cannot marshal response", 13)
	}
	return string(out), nil
}

```

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [November 17, 2022, 7:30pm UTC](https://forum.heroiclabs.com/t/failed-initializing-runtime-modules-plugin-was-built-with-a-different-version-of-package-google-golang-org-protobuf-internal-pragma/3265/6 "2022-11-17T19:30:04Z")

</div>

The `InitModule` func should have the following signature:  
`InitModule(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, iz runtime.Initializer) error`

---

<div class="post-metadata">

**Author:** ![technicallyty](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/technicallyty/32/1435_2.png) [@technicallyty](https://forum.heroiclabs.com/u/technicallyty)\
**Post date:** [November 17, 2022, 8:09pm UTC](https://forum.heroiclabs.com/t/failed-initializing-runtime-modules-plugin-was-built-with-a-different-version-of-package-google-golang-org-protobuf-internal-pragma/3265/7 "2022-11-17T20:09:11Z")

</div>

ahh weird. i swear i copy pasted the signature from the docs… maybe i messed up the selection…

all good and working now though! also noticed that any changes to the code require me to use the flag --build:

```auto
docker compose up --build

```

so it rebuilds the src, at first i thought the updated sig wasn’t working 😅

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [November 18, 2022, 11:03am UTC](https://forum.heroiclabs.com/t/failed-initializing-runtime-modules-plugin-was-built-with-a-different-version-of-package-google-golang-org-protobuf-internal-pragma/3265/8 "2022-11-18T11:03:31Z")

</div>

We’ll fix the docs regarding the mismatched versions and consider mentioning the `--build` flag too in the docs so others don’t run into the same issue.
