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

config: set RCLONE_CONFIG_DIR for use in config files and subprocesses

Nick Craig-Woodb62d08d13681
diff --git a/docs/content/docs.md b/docs/content/docs.md
index a1d0a9d94..e728cbb98 100644
--- a/docs/content/docs.md
+++ b/docs/content/docs.md
@@ -1770,7 +1770,8 @@ you must create the `..._TYPE` variable as above.
### Other environment variables ###
- * `RCLONE_CONFIG_PASS` set to contain your config file password (see [Configuration Encryption](#configuration-encryption) section)
- * `HTTP_PROXY`, `HTTPS_PROXY` and `NO_PROXY` (or the lowercase versions thereof).
- * `HTTPS_PROXY` takes precedence over `HTTP_PROXY` for https requests.
- * The environment values may be either a complete URL or a "host[:port]" for, in which case the "http" scheme is assumed.
+- `RCLONE_CONFIG_PASS` set to contain your config file password (see [Configuration Encryption](#configuration-encryption) section)
+- `HTTP_PROXY`, `HTTPS_PROXY` and `NO_PROXY` (or the lowercase versions thereof).
+ - `HTTPS_PROXY` takes precedence over `HTTP_PROXY` for https requests.
+ - The environment values may be either a complete URL or a "host[:port]" for, in which case the "http" scheme is assumed.
+- `RCLONE_CONFIG_DIR` - rclone **sets** this variable for use in config files and sub processes to point to the directory holding the config file.
diff --git a/fs/config/config.go b/fs/config/config.go
index e0ded4ef8..f7066ad83 100644
--- a/fs/config/config.go
+++ b/fs/config/config.go
@@ -213,6 +213,9 @@ func makeConfigPath() string {
// LoadConfig loads the config file
func LoadConfig() {
+ // Set RCLONE_CONFIG_DIR for backend config and subprocesses
+ _ = os.Setenv("RCLONE_CONFIG_DIR", filepath.Dir(ConfigPath))
+
// Load configuration file.
var err error
configFile, err = loadConfigFile()