Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

Use rclone.conf from rclone executable directory if already existing

albertony976a020a2f48
diff --git a/docs/content/docs.md b/docs/content/docs.md
index f65289032..f6b9aedd2 100644
--- a/docs/content/docs.md
+++ b/docs/content/docs.md
@@ -452,7 +452,11 @@ Specify the location of the rclone config file.
Normally the config file is in your home directory as a file called
`.config/rclone/rclone.conf` (or `.rclone.conf` if created with an
older version). If `$XDG_CONFIG_HOME` is set it will be at
-`$XDG_CONFIG_HOME/rclone/rclone.conf`
+`$XDG_CONFIG_HOME/rclone/rclone.conf`.
+
+If there is a file `rclone.conf` in the same directory as the rclone
+executable it will be preferred. This file must be created manually
+for Rclone to use it, it will never be created automatically.
If you run `rclone config file` you will see where the default
location is for you.
diff --git a/fs/config/config.go b/fs/config/config.go
index c48a2f885..01230f77b 100644
--- a/fs/config/config.go
+++ b/fs/config/config.go
@@ -105,6 +105,18 @@ func getConfigData() *goconfig.ConfigFile {
// Return the path to the configuration file
func makeConfigPath() string {
+
+ // Use rclone.conf from rclone executable directory if already existing
+ exe, err := os.Executable()
+ if err == nil {
+ exedir := filepath.Dir(exe)
+ cfgpath := filepath.Join(exedir, configFileName)
+ _, err := os.Stat(cfgpath)
+ if err == nil {
+ return cfgpath
+ }
+ }
+
// Find user's home directory
homeDir, err := homedir.Dir()