New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin: panic: plugin was built with a different version of package #27751

Open
juhwany opened this Issue Sep 19, 2018 · 7 comments

Comments

Projects
None yet
6 participants
@juhwany

juhwany commented Sep 19, 2018

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.11 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN="/Users/juhwany/go_workspace/bin"
GOCACHE="/Users/juhwany/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/juhwany/go_workspace"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/juhwany/gos/go_server/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/mk/2tyywdsn0jq6l0vl8094tss80000gp/T/go-build380269681=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

  1. Clone the blow repo in each directory. (not under GOPATH)
    server (main program) : https://github.com/juhwany/go_server
    plugin : https://github.com/juhwany/go_plugin

  2. On same machine, build server & plugin in each directory
    Build server : go build -o main
    Build plugin : go build -buildmode=plugin -o plugin.so

  3. Copy plugin.so to server directory and run
    ./main

  4. See error message when main program try to open plugin.

panic: plugin.Open("plugin"): plugin was built with a different version of package github.com/juhwany/go_server/v2/apis

What did you expect to see?

Main program should load plugin.so successfully.
I could not understand why it fails even though the referenced package version is same between main program and plugin.
Am I using plugin in wrong way?

What did you see instead?

plugin was built with a different version of package error message

@juhwany juhwany changed the title from plugin was built with a different version of package to plugin was built with a different version of package error Sep 19, 2018

@randall77

This comment has been minimized.

Contributor

randall77 commented Sep 19, 2018

Related (dup?) #26759 .

@juhwany

This comment has been minimized.

juhwany commented Sep 20, 2018

@randall77

No. I think building environment is slightly different from #26759.
I didn't build main program and plugin under GOPATH and the above sample project uses Go module for specifying dependency package. Go version is also different.

@BryceDFisher

This comment has been minimized.

BryceDFisher commented Sep 21, 2018

I do think they are all related though, including #27062. I think it all boils down to changing (absolute) paths at build time between the plugin build and the app build.

@bcmills

This comment has been minimized.

Member

bcmills commented Sep 22, 2018

@bcmills bcmills changed the title from plugin was built with a different version of package error to plugin: panic: plugin was built with a different version of package Sep 22, 2018

@bcmills bcmills added this to the Go1.12 milestone Sep 22, 2018

@tamasf97

This comment has been minimized.

tamasf97 commented Oct 8, 2018

I'm not sure if anyone's already mentioned it, but putting the common(apis) package to a separate module outside the server one will work. It's definitely cumbersome, but can be used as a workaround until this issue is fixed.

@oszika

This comment has been minimized.

oszika commented Nov 13, 2018

The command "go list -m -json all" shows version of go_server on go_plugin, but it's not defined on go_server itself. I have a similar problem using multiples modules on the same repository using "replace" directive. I don't know how to have the same version of the module inside and outside the repository.

@oszika

This comment has been minimized.

oszika commented Dec 1, 2018

In #28983, @bcmills suggests to build plugins from within the main module.

// server/go.mod
module github.com/juhwany/go_server/v2
require github.com/juhwany/plugin v0.0.0
replace github.com/juhwany/plugin => ../go_plugin

$ go build -buildmode=plugin github.com/juhwany/plugin
$ go run main.go 
DoSomething called!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment