plugin: go build -plugin
included package versions seem to be affected by *other* modules in the same workspace
#58639
Labels
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, I tried 1.20.1. I can also reproduce it on Linux Intel
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I try to build a plugin, which is a module in workspace, and then use it in another go application.
Minimal example is here, as it involves three different modules and one workspace
https://github.com/karelbilek/go-pluginbug-example
mymain/
is a main module that calls plugin.Open.work/myplugin
is a plugin code.work/myother
is an unrelated package../build.sh
does the operation of building work/myplugin as a plugin, then moving it to mymain/ and loading it.What did you expect to see?
Everything will work, as mymain/ and work/myplugin are using same version of the dependency
golang.org/x/sys/execabs
.What did you see instead?
panic: plugin.Open("myplugin"): plugin was built with a different version of package golang.org/x/sys/execabs
When I remove
work/go.work
, everything works. When the "unrelated" module work/myother is using same version, everything work.It seems like the version of
golang.org/x/sys/execabs
in a different module in the same workspace is affecting, which version is included when built as a-plugin
. I don't think this is an expected behaviour; it certainly is not intuitive.This is actually a root cause of this issue in golangci-lint - golangci/golangci-lint#3603 (golangci-lint supports private linters that are loaded as plugins).
I am not sure what dependency is actually built into the plugin; if the bigger one, or the smaller one.
The text was updated successfully, but these errors were encountered: