Rclone plugin complains about different version of package github.com/rclone/rclone/fs/config/configmap

What is the problem you are having with rclone?

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:

github.com/rclone/rclone v1.56.2 h1:Q4noh/6Xqh1Qu07C+4HbJcreVtCFOw5Z2lP0/SYIp7o=
github.com/rclone/rclone v1.56.2/go.mod h1:q4QZJCi83S+LGp3GHv2lM+0PCAUa05Je5zNtn7GthSw=

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

:confused:

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 :slight_smile: 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.

Update:
same trouble with everything up to date:

Update 2:
the build command

go build -trimpath -buildmode=plugin -o ./bin/librcloneplugin_backend_sharelink.so . 

I really didn't think it would matter but figured I'd ask.

I'd think @ncw or @ole or maybe one of the other guys can help out as I don't build much (ever really).

Hi Mickael,

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:

Hi Ole,

Thank you for your time.
Here is a very basic plugin, still it does not work for me :frowning:

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 :slightly_smiling_face:

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.

I think things to check would be

  • 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:

rclone --version
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

I had a play with your example module.

I needed to checkout a copy of the rclone source at v1.57.0 and point the go.mod to it

diff --git a/go.mod b/go.mod
index 58e8838..b0cd402 100644
--- a/go.mod
+++ b/go.mod
@@ -13,3 +13,5 @@ require (
        golang.org/x/sys v0.0.0-20210820121016-41cdb8703e55 // indirect
        golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
 )
+
+replace github.com/rclone/rclone => /home/ncw/go/src/github.com/rclone/rclone

I build rclone from that source using make.

I had to remove the -trimpath from your makefile as I wasn't doing a release build and these flags need to match too.

diff --git a/Makefile b/Makefile
index ac074f8..055b3c8 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 build:
-       go build -trimpath -buildmode=plugin -o ./bin/librcloneplugin_backend_mwe.so .
+       go build -buildmode=plugin -o ./bin/librcloneplugin_backend_mwe.so .
        cp -f ./bin/librcloneplugin_backend_mwe.so ${RCLONE_PLUGIN_PATH}/librcloneplugin_backend_mwe.so
 
 clean:

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.

If you build rclone yourself then you should be able to get the plugin to work straight away I would have thought.

Unfortunately the go plugin system appears to be rather fussy about build flags...

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.