Open
Description
What version of Go are you using (go version
)?
$ go version go version go1.21.1 linux/amd64
Does this issue reproduce with the latest release?
Y
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE='' GOARCH='amd64' GOBIN='' GOCACHE='/home/mfreeman/.cache/go-build' GOENV='/home/mfreeman/.config/go/env' GOEXE='' GOEXPERIMENT='' GOFLAGS='' GOHOSTARCH='amd64' GOHOSTOS='linux' GOINSECURE='' GOOS='linux' GOPROXY='https://proxy.golang.org,direct' GOROOT='/usr/local/go' GOSUMDB='sum.golang.org' GOTMPDIR='' GOTOOLCHAIN='auto' GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64' GOVCS='' GOVERSION='go1.21.1' GCCGO='gccgo' GOAMD64='v1' AR='ar' CC='gcc' CXX='g++' CGO_ENABLED='1' GOWORK='' CGO_CFLAGS='-O2 -g' CGO_CPPFLAGS='' CGO_CXXFLAGS='-O2 -g' CGO_FFLAGS='-O2 -g' CGO_LDFLAGS='-O2 -g' PKG_CONFIG='pkg-config' GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build4277136579=/tmp/go-build -gno-record-gcc-switches'
What did you do?
go build -buildmode=plugin -o ./handler.so ./main.go
Then when I tried to use it with another program:
2023/09/29 02:11:29 main.go:26: plugin error: plugin.Open("/plugin/handler"): plugin was built with a different version of package google.golang.org/protobuf/internal/pragma
What did you expect to see?
It should tell me what the different version is so I can match it.
What did you see instead?
Nothing other than a not very useful message telling me that I have the wrong version, but not what the correct version should be.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Todo
Milestone
Relationships
Development
No branches or pull requests
Activity
[-]affected/package: go plugin system[/-][+]plugin: report the version of Go used to build a plugin when a mismatch occurs[/+]cherrymui commentedon Sep 29, 2023
You can run
go version -m handler.so
andgo version -m <main_executable>
to find out the versions and how they differ. Would that be helpful?mfreeman451 commentedon Sep 29, 2023
quantonganh commentedon Oct 17, 2023
I'm afraid that there are some cases where
go version -m
cannot help.plugin/myplugin.go
:main.go
:Build the plugin:
$ cd plugin $ go build -buildmode=plugin -mod=vendor -o myplugin.so myplugin.go
Build the main program:
The root cause might be something else: the full file path, the build flags, ... not the package version. Moreover, I'm not sure if we can tell what the different versions are. I tried to make a change here:
but what I got is something like this:
thepudds commentedon Dec 30, 2024
Hi @quantonganh, for your specific example in #63290 (comment), were you able to resolve the issue? Also, I’m not sure if this would help, but I’m curious if you tried building with -trimpath.