Auto config file write?

What is the problem you are having with rclone?

In short:
rclone automatically writes the config file when running (mount). Why and what is it actually doing? Can I disable this?

Full:

I made a independent rclone copy and a config file with a single Google Drive remote. I also made a simple cmd script (the actual command is in the next section, just a single cmd command) to mount the GD remote. All stored in a USB flash drive.
Each time I boot my computer, I plug in the USB drive, run the script, and remove the USB drive from my computer.

When I look into the output, it keep saying errors that failed to save config files. Of course, the drive is removed.
Besides this, everything is fine. The remote Google Drive works properly.

But it gives me a small trouble when I plug in some other removable drive that takes the partition letter of the USB flash drive, rclone config is saved to that drive. This causes inconvenience and security issues.

I did do a quick search and read the official rclone document briefly and I did not find something related.

Can anyone please tell me why is necessary to keep writing a config file? Is it just making an identical copy or anything updated?
Also, is it possible to disable this action?

Very appreciated.

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

Windows LTSC 2019 (1809)

rclone-v1.57.0-windows-386

2022/04/02 21:42:49 ERROR : Failed to save config after 10 tries: failed to create config directory: mkdir H:\: The system cannot find the path specified.

(this error message repeats)

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

Google Drive

The command you were trying to run (eg rclone copy /tmp remote:tmp)

rclone --config %~d0\rclone\config\rclone.conf mount **remote name redacted**: Q: --vfs-cache-mode full --vfs-cache-max-size 1G

The rclone config contents with secrets removed.

encrypted.

decrypted would be:

[**remote name redacted**]
type = drive
client_id = **redacted**.apps.googleusercontent.com
client_secret = GOCSPX-**redacted**
scope = drive
token = {"access_token":"**redacted**","token_type":"Bearer","refresh_token":"**redacted**","expiry":"2022-03-31T02:42:42.1840208-07:00"}
team_drive =

A log from the command with the -vv flag

The token changes every hour and rclone writes it back to the config file, so this is a necessary part of rclone's operation.

try using a gdrive service account file.
does not use a token and rclone might not try to access the config file.

for example,

[gdrivesa]
type = drive
scope = drive
service_account_file = C:\data\rclone\gdrive.sa\test01-309420-6f8144bb217f.json

and here is a script that does not use a config file, creates the remote on the fly

@set RCLONE_CONFIG_GDRIVESAC_TYPE=drive
@set RCLONE_CONFIG_GDRIVESAC_SCOPE_=DRIVE
@set RCLONE_CONFIG_GDRIVESAC_SERVICE_ACCOUNT_CREDENTIALS={"type": "service_account",  "project_id": "test01-309420",   "private_key_id": "xyz",   "private_key": "-----BEGIN PRIVATE KEY----------END PRIVATE KEY-----\n",   "client_email": "xyz",   "client_id": "xyz",   "auth_uri": "https://accounts.google.com/o/oauth2/auth",   "token_uri": "https://oauth2.googleapis.com/token",   "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",   "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/test02%40test01-309420.iam.gserviceaccount.com" }

rclone mount gdrivesac: b:\rclone\mount\gdrivesac -vv 
DEBUG : rclone: Version "v1.57.0" starting with parameters ["C:\\data\\rclone\\rclone.exe" "mount" "gdrivesac:" "b:\\rclone\\mount\\gdrivesac" "-vv"]
DEBUG : Creating backend with remote "gdrivesac:"
DEBUG : Setting type="drive" for "gdrivesac" from environment variable RCLONE_CONFIG_GDRIVESAC_TYPE
DEBUG : Setting service_account_credentials=" {\"type\": \"service_account\",  \"project_id\": \"test01-309420\",   \"private_key_id\": \"xyz\",   \"private_key\": \"-----BEGIN PRIVATE KEY----------END PRIVATE KEY-----\\n\",   \"client_email\": \"xyz\",   \"client_id\": \"xyz\",   \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",   \"token_uri\": \"https://oauth2.googleapis.com/token\",   \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",   \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/xyz\" }" for "gdrivesac" from environment variable RCLONE_CONFIG_GDRIVESAC_SERVICE_ACCOUNT_CREDENTIALS
DEBUG : gdrivesac: detected overridden config - adding "{5N7NI}" suffix to name
DEBUG : Using config file from "C:\\Users\\user01\\AppData\\Roaming\\rclone\\rclone.conf"
DEBUG : Setting service_account_credentials=" {\"type\": \"service_account\",  \"project_id\": \"test01-309420\",   \"private_key_id\": \"xyz\",   \"private_key\": \"-----BEGIN PRIVATE KEY----------END PRIVATE KEY-----\\n\",   \"client_email\": \"xyz\",   \"client_id\": \"xyz\",   \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",   \"token_uri\": \"https://oauth2.googleapis.com/token\",   \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",   \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/xyz\" }" for "gdrivesac" from environment variable RCLONE_CONFIG_GDRIVESAC_SERVICE_ACCOUNT_CREDENTIALS
DEBUG : Google drive root '': 'root_folder_id = xyz' - save this in the config to speed up startup
DEBUG : fs cache: renaming cache item "gdrivesac:" to be canonical "gdrivesac{5N7NI}:"
DEBUG : Network mode mounting is disabled
DEBUG : Mounting on "b:\\rclone\\mount\\gdrivesac" ("gdrivesac{5N7NI}")
DEBUG : Google drive root '': Mounting with options: ["-o" "attr_timeout=1" "-o" "uid=-1" "-o" "gid=-1" "--FileSystemName=rclone" "-o" "volname=gdrivesac{5N7NI}"]
DEBUG : Google drive root '': Init: 
DEBUG : Google drive root '': >Init: 
DEBUG : /: Statfs: 
DEBUG : /: >Statfs: stat={Bsize:4096 Frsize:4096 Blocks:3932160 Bfree:3932094 Bavail:3932094 Files:1000000000 Ffree:1000000000 Favail:0 Fsid:0 Flag:0 Namemax:255}, errc=0
DEBUG : /: Getattr: fh=0xFFFFFFFFFFFFFFFF
DEBUG : /: >Getattr: errc=0
DEBUG : /: Readlink: 
DEBUG : /: >Readlink: linkPath="", errc=-40
The service rclone has been started.

Thanks!

But even though the token is not updated for a long time. Next time I plug in my drive and mount, everything always works fine.

Interesting!
Thank you for your advice and script!

But if the SA file is offline (I store it in a USB drive and remove the drive once mount), will it still work?

Rclone will refresh the token using the refresh token every time it starts. Eventually the refresh token will expire too and it will stop working. I don't know exactly how long the refresh tokens last though - maybe 3 months?

as far as i know, the answer is, it will still work.
tho ncw can confirm?

in any event, take a look at my example:
--- does not use a config file.
--- does not use a SA file.
--- the remote is created, in the fly, by the batch file.
--- the account credentials are added using
@set RCLONE_CONFIG_GDRIVESAC_SERVICE_ACCOUNT_CREDENTIALS={"type": "service_account", "project_id": "test01-309420", "private_key_id": "xyz", "private_key": "-----BEGIN PRIVATE KEY----------END PRIVATE KEY-----\n", "client_email": "xyz", "client_id": "xyz", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://oauth2.googleapis.com/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/test02%40test01-309420.iam.gserviceaccount.com" }

another option is to create the remote, on the fly, using rclone config create

I think it will work, yes.

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