-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: loading on machine with different GOPATH fails #26759
Comments
I don't think that's intentional. The version mismatch is not between the plugin and the Go installation, it is between the Go installation that built the plugin and the Go installation that built the main program. Where was the main binary built? (You don't need the Go installation on the server at all, at least to run Go binaries and plugins.) I can install two identical |
@randall77 Yes the main file is build by a different installation of go on a different machine(which only differs in gopath) Basically what I am doing is building a plugin that references some model.go, and serve the model and plugin to the client so they can write program of their own. that is
build a plugin.so and serve the so and model to user, the user may write a program on their machine like
Essentially I need to hide the implementation of the |
@randall77
build plugin
copy the plugin from docker container environment 2(differ only in gopath)
use plugin in env2
|
It will work by using plugin in env1 in the same way |
I still can't reproduce your issue. Your plugin runs fine for me. I've never used Docker, unfortunately, so I don't know what things like "use plugin in env2" mean. |
|
Ok, my bad. I was thinking GOROOT, not GOPATH. I am now able to reproduce.
If you do:
The version check is using the hash of some header information in the exported information from the The full path just appears in the filenames. I'm not sure that's relevant information to be hashing. For source code from GOROOT, the path starts at $GOROOT/src/... but for source from GOPATH the full path is used. I can understand why, as GOPATH can have colon-separated paths and it would not be clear which one was the source of the file in question. |
@randall77 |
No progress. I think I understand the problem but I have no idea what the fix might be. |
This is the same problem that I opened with #27062, except in my case the "vendor" directory was being included in the full file path, which messed up the package tracking from the plugin. Should I close my original issue to consolidate here? |
I don't think they are quite the same issue. This one is the exact same import path in both the plugin and main build. #27062 has paths differ by the vendor prefix. |
Once we do #16860, we can make it kick in for plugins automatically. For now, nothing to do for Go 1.12. |
…olang/go#26759 for more details Signed-off-by: Oleg Sidorov <me@whitebox.io>
Any news regarding this issue? I am struggling distributing plugins to third-party users. I have tried as many build options as possible but still no success. |
What version of Go are you using (
go version
)?go version go1.10.3 linux/amd64
Does this issue reproduce with the latest release?
Yes?
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOCACHE="/home/blablabla/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/go"
GORACE=""
GOROOT="/opt/go"
GOTMPDIR=""
GOTOOLDIR="/opt/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build657274199=/tmp/go-build -gno-record-gcc-switches"
What did you do?
I build a go plugin from a docker image and copy it to a server. They have essentially the same go env except for the go path. (One was
/go
the other/home/username/go
)When I tried to load the plugin from other server, I always get
panic: plugin.Open("./parser"): plugin was built with a different version of package xxxx
It can only be fixed by setting the gopath the same as that in the docker image I used to build the plugin
I don't know if this is a bug or it is just how go plugin works.
Thanks.
The text was updated successfully, but these errors were encountered: