Rclone rc data types query

What is the problem you are having with rclone?

I'm having some trouble using strings with rclone rc options/set. Most likely just a misunderstanding on my part!

Run the command 'rclone version' and share the full output of the command.

rclone v1.60.1
- os/version: debian 11.5 (64 bit)
- os/kernel: 5.10.0-19-amd64 (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.19.3
- go/linking: static
- go/tags: none

Which cloud storage system are you using? (eg Google Drive)

Google Drive

I have a systemd service like so:

ExecStart=/usr/local/bin/rclone rcd \
	--rc-addr= \
	--rc-htpasswd=/root/.rclone_web.htpasswd \
	--rc-enable-metrics \
	--config=/root/.config/rclone/rclone.conf \
	--cache-dir=/mnt/scratch/rclone \
	--log-level INFO \
	--log-file=/var/log/rclone/rcd.log \

# Set global opts
ExecStartPost=/usr/local/bin/rclone rc options/set \
	--user 'rclone' --pass 'redacted' \
	--json '{"main": {"UserAgent": "rclone-gdrive", "Timeout": 3600000000000}, "mount": {"AllowOther": true}, "vfs": {"Umask": 2, "UID": 1000, "GID": 1000, "PollInterval": 15000000000, "DirCacheTime": 3600000000000000, "CacheMaxAge": 129600000000000, "CacheMaxSize": 322122547200, "CacheMode": 3}}'

# Mount remote
ExecStartPost=/usr/local/bin/rclone rc mount/mount \
	--user 'rclone' --pass 'redacted' \
	fs=gdrive-media-crypt:media mountPoint=/mnt/gmedia-cloud

With the rclone rc options/set command, I'm using integers. Having read the data types section of the rc docs, I decided to swap these for shorthand strings, for the sake of simplicity.

To make sure I got it right, I ran this before amending the systemd service (I'm aware 3600000000000 != 5s, just testing here):
rclone rc --user=rclone --pass='redacted' options/set --json '{ "main": {"Timeout": "5s"}}'

However, I received the following error:

2022/11/30 14:48:48 Failed to rc: failed to read rc response: 500 Internal Server Error: {
	"error": "failed to write options from block \"main\": Reshape failed to Unmarshal: json: cannot unmarshal string into Go struct field ConfigInfo.Timeout of type time.Duration",
	"input": {
		"main": {
			"Timeout": "5s"
	"path": "options/set",
	"status": 500

Am I misunderstanding something here? That seems most likely.... Any tips would be appreciated!


Hmm, I would have thought that should work.

Maybe it is because the type is a time.Duration not an fs.Duration.

I can't remember his this works right now (not at computer)...

Can you find some which do work set as a string or is it completely broken?

Yes, sizes seem to work fine from some limited testing:

$ rclone rc --user=rclone --pass='redacted' options/get | jq .main.BufferSize
$ rclone rc --user=rclone --pass='redacted' options/set --json '{ "main": {"BufferSize": "1G"}}'
$ rclone rc --user=rclone --pass='redacted' options/get | jq .main.BufferSize

likewise for enumerated types:

$ rclone rc --user=rclone --pass='redacted' options/get | jq .vfs.CacheMode
$ rclone rc --user=rclone --pass='redacted' options/set --json '{ "vfs": {"CacheMode": "minimal"}}'
$ rclone rc --user=rclone --pass='redacted' options/get | jq .vfs.CacheMode

and bandwidth specs:

$ rclone rc --user=rclone --pass='redacted' options/get | jq .main.BwLimit
$ rclone rc --user=rclone --pass='redacted' options/set --json '{ "main": {"BwLimit": "1G"}}'
$ rclone rc --user=rclone --pass='redacted' options/get | jq .main.BwLimit

So it looks like it's just durations which aren't working :slight_smile:

Thank you for testing.

I found an easy way to reproduce

$ rclone rc --loopback options/set --json '{ "main": {"Timeout": "5s"}}'
2022/12/01 11:43:18 Failed to rc: loopback call failed: failed to write options from block "main": Reshape failed to Unmarshal: json: cannot unmarshal string into Go struct field ConfigInfo.Timeout of type time.Duration

This would mean changing all the time.Duration declarations into fs.Duration which would make an awful lot of ripple through changes :frowning:

I changed Timeout to see what would happen and ended up making about 10 changes!

We recently allowed all time.Timeout parameters to be parsed as fs.Duration on the command line so you can say --timeout 3w which you couldn't do before.

I need to think of a clever way of doing the same for the rc parameters if I want to avoid changing all the time.Duration definitions.


No problem, thanks for the quick response!

Good to know it's not just a me-problem and I've been able to bring this to light.

Sounds like a tricky one, and unfortunately beyond me, otherwise I'd love to help.

Would you like me to open a GitHub issue with my findings so the problem can be tracked over there?

Yes that's a good idea - can you open a new issue on Github. I think I might just fix the docs, but I need to think about it for a bit to see if there is a clever solution :slight_smile:

1 Like

Sure, whatever works best! Sounds like a docs update is the significantly easier solution :wink:

1 Like

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