I am building a custom backend plugin for rclone, compilation seems to work fine. But once I try to use my plugin on my local rclone I got an error message:
Failed to load plugin librcloneplugin_backend_sharelink.so: plugin.Open("/Users/mcamier/workspace/kdrive-rclone/kdrivesharelink/bin/librcloneplugin_backend_sharelink"): plugin was built with a different version of package github.com/rclone/rclone/fs/config/configmap
I dont understand why this package produces this issue, since the rclone's version match. Pleace find below the result of "rclone --version"and this excerpt of my go.sum file:
Run the command 'rclone version' and share the full output of the command.
rclone --version
Failed to load plugin librcloneplugin_backend_sharelink.so: plugin.Open("/Users/mcamier/workspace/kdrive-rclone/kdrivesharelink/bin/librcloneplugin_backend_sharelink"): plugin was built with a different version of package github.com/rclone/rclone/fs/config/configmap
rclone v1.56.2
- os/version: darwin 12.1 (64 bit)
- os/kernel: 21.2.0 (x86_64)
- os/type: darwin
- os/arch: amd64
- go/version: go1.16.8
- go/linking: dynamic
- go/tags: cmount
I got the same issue with the latest version (1.57.0)
Which cloud storage system are you using? (eg Google Drive)
my own, since I try to use my backend plugin
The command you were trying to run (eg rclone copy /tmp remote:tmp)
rclone --version
or other rclone commands since they try to load the plugins available in path describe in env var "RCLONE_PLUGIN_PATH"
The rclone config contents with secrets removed.
not relevant here but I can show my golang version, since it's a prerequisite for plugin making
go version
go version go1.16.8 darwin/amd64
A log from the command with the -vv flag
rclone --version -vv
Failed to load plugin librcloneplugin_backend_sharelink.so: plugin.Open("/Users/mcamier/workspace/kdrive-rclone/kdrivesharelink/bin/librcloneplugin_backend_sharelink"): plugin was built with a different version of package github.com/rclone/rclone/fs/config/configmap
2022/01/26 16:11:14 DEBUG : rclone: Version "v1.56.2" starting with parameters ["rclone" "--version" "-vv"]
rclone v1.56.2
- os/version: darwin 12.1 (64 bit)
- os/kernel: 21.2.0 (x86_64)
- os/type: darwin
- os/arch: amd64
- go/version: go1.16.8
- go/linking: dynamic
- go/tags: cmount
Super doubt that is of any value, but that's an old version of rclone and an older version of GO. If you are building from the github, they might need to be on similar levels.
I am not sure as I like things in sync so I always start there.
It makes sense, but unfortunately I tried with rclone 1.57.0 and go 1.17.2 and I ended up in the same situation, same error message. I will try one more time and let you know.
rclone plugins are outside my area of knowledge/experience, so I cannot help you with the specific error.
It may be my lack of knowledge, but there seem to be many unknowns in the description of your situation which may make it difficult to help you, even if knowledgeable.
I therefore suggest you try with a very simple “Hello World from plugin” (using the latest stable) to verify your understanding and rclone functioning correctly.
If this errors too, then share the full code and setup used to build your “Hello World plugin”.
That is, try building a Minimum Reproduceable Example:
Thank you for your time.
Here is a very basic plugin, still it does not work for me
You can pull it and then run "make build", it will compile then copy the .so into your RCLONE_PLUGIN_PATH.
once done, you can run "rclone --version" in you shell and you should get an error like I do:
rclone --version
Failed to load plugin librcloneplugin_backend_mwe.so: plugin.Open("/*RCLONE_PLUGIN_PATH*/librcloneplugin_backend_mwe"): plugin was built with a different version of package github.com/rclone/rclone/fs/config/configmap
rclone v1.57.0
- os/version: darwin 12.1 (64 bit)
- os/kernel: 21.2.0 (x86_64)
- os/type: darwin
- os/arch: amd64
- go/version: go1.17.2
- go/linking: dynamic
- go/tags: none
for now the only solution I oversee is to pull the rclone in my Dockerfile, append my plugin's files into it then compile the whole thing. but it's a bit cumbersome and will unnecessarily increase my build time.
Great, ready for analysis by somebody with good rclone/plugin/Go knowledge/experience
Your issue is very technical, so you may get better attention from the core developers by creating a GitHub issue with a link to this post, just in case nobody drops by later today.
Did both plugin and rclone get built using exactly the same source tree?
git checkout v1.56.2 should get you the right code
this should have the same dependencies
you shouldn't have to do this, but you can downlod the vendorball on the GitHub releases page which is all the libraries the release build was built with. Unpack this into the vendor directory.
Did both plugin and rclone get built with the same Go version? Looking at the above I think this is probably the problem.
The main docs are silent on compatibility issues, alas, but a squint at the Go source code leads me to believe that the "version" in question includes the Go version as well as the code version.
I don't rely understand what you say.
First, for the version of Go, as I shown, they are both the same since go version returns "go version go1.17.2 darwin/amd64" and rclone --version returns " go/version: go1.17.2". those are the same release version so I expect to be the exact same code.
Then why should I perform a "git checkout v.1.57.0" (or whatever version), since I already have:
require (
github.com/rclone/rclone v1.57.0
)
in the go.mod, Go handle the fetching of the source for me, and again, it's the same version as shown:
Then the plugin would build and load without complaint.
I think you are targeting the pre-built binaries on macOS. I can't test that as I don't have a mac and on Linux the pre-buillt binaries are made without CGO which means they can't load plugins, but I think the above should work - you should only need the go.mod patch.
Modules seems to have made building plugins a lot harder so I expect we need to update the docs.
/tmp/rclone_plugin_mwe$ rclone version
rclone v1.57.0
- os/version: ubuntu 21.10 (64 bit)
- os/kernel: 5.13.0-27-generic (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.17.2
- go/linking: dynamic
- go/tags: none
/tmp/rclone_plugin_mwe$ go version
go version go1.17.2 linux/amd64
/tmp/rclone_plugin_mwe$ rclone lsf :dummy:
2022/01/28 11:22:54 Failed to create file system for ":dummy:": implement me
Thank you for your response.
Unfortunately this doesn't help solving the issue, even with the change you advice, I got a similar error but on different packages depending I use -trimpath or not (internal/unsafeheader, golang.org/x/sys/internal/unsafeheader).
For now I will consider the plugin system broken and fallback on building the whole rclone project along with my new backend.