"Failed to create temp file for new config" weird logging and workarounds

What is the problem you are having with rclone?

rclone logs Failed to save config after 10 tries: failed to create temp file for new config: open /.rclone.conf4240129501: permission denied as ERROR while in my opinion it should log this as a WARNING.

I am trying to use bitnami/rclone:1.69.1 to run rclone in a k8s cronjob.
Since I use the image in a Helm chart, I inject the whole config as environment variables e.g. RCLONE_CONFIG_<SOURCENAME>_URL etc.

I think the problem is that in bitnami's rclone image, the user that the container uses does not have a home directory so its home directory is /.
rclone tries to write the config temp file to / and then (I think) moving it to its set config directory. I've seen though that even if it logs that as an error, rclone still copies/syncs the files between the sources, so it works as intended. I think that after trying to write the temp config file in /, it tries to write it elsewhere, in a directory where the user can write.

I must say that this error does not occur when I am running the community rclone/rclone:1.69.1 image from Docker Hub, since it uses root.

Is there a way to set the rclone temp config file directory to another directory with write permissions? I've tried browsing the docs but besides Documentation, I didn't really found much.
I've tried setting RCLONE_CONFIG_DIR and XDG_CONFIG_HOME but nothing much happened. Setting HOME to /tmp worked but it seems more like a workaround than a fix.

Am I doing something wrong here? I think I'm missing something.

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

rclone v1.69.1
- os/version: debian 12.10 (64 bit)
- os/kernel: 5.10.219-208.866.amzn2.x86_64 (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.23.7
- go/linking: dynamic
- go/tags: none

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

S3, SFTP, HTTP...

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

copy 'dest:' --filter='+ /**' --filter='- **' source:foo-bucket/baz --use-json-log                                                

Please run 'rclone config redacted' and share the full output. If you get command not found, please make sure to update rclone.

2025/03/17 19:59:50 NOTICE: Config file "/.rclone.conf" not found - using defaults
; empty config

Here's the config environment variables that have been set:

RCLONE_CONFIG_DIR=/tmp/rclone/config
RCLONE_CONFIG_SOURCE_ENV_AUTH=true
RCLONE_CONFIG_DEST_PASS=rclone_obscured_password
RCLONE_CONFIG_SOURCE_TYPE=s3
RCLONE_CONFIG_DEST_HOST=sftp.foo.com
RCLONE_CONFIG_DEST_USER=user
RCLONE_CONFIG_DEST_TYPE=sftp
RCLONE_CONFIG_SOURCE_REGION=aws-region
RCLONE_CONFIG_SOURCE_PROVIDER=AWS

A log from the command that you were trying to run

Config file "/config/rclone/rclone.conf" not found - using defaults
Failed to save config after 10 tries: failed to create temp file for new config: open /.rclone.conf4240129501: permission denied
< auth and files sync DEBUG and INFO logs>

Set your Temp dir to somewhere writable:

/tmp is writable by the user.
The problem is that rclone tries to write the temp config file in / (no write permissions) and not in /tmp where the user can write.

I'm on Linux so by default it should be /tmp

Yes, but:

By default the operating system's temp directory will be used:

  • On Unix systems, $TMPDIR if non-empty, else /tmp.

If $TMPDIR points into / then rclone tries to write there.

Overwrite it with --temp-dir=/tmp or env variable RCLONE_TEMP_DIR=/tmp

in my case $TMPDIR is empty though so it should default to /tmp but it seems that it doesn't?
setting $TMPDIR=/tmp works indeed though.

I do not know your system config details but instead of changing OS global variable to solve one issue (and maybe create a new one somewhere else:)) I would only explicitly set RCLONE_TEMP_DIR to make rclone happy.

I've tried setting only RCLONE_TEMP_DIR=/tmp but it seems that's not enough, I still get those errors.
If I set RCLONE_TEMP_DIR, RCLONE_CONFIG_DIR and XDG_CONFIG_HOME to /tmp works indeed.

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