Rclone configuration

.config existed before I looked at it.
Anyways, I changed the way I have rights for .config and now it works.
(I will undo it again, because I like it the way I have now (all together in just 1 directory)

The date shows it was just created yesterday:

image

Not sure what that means, but if you are working in however you have it setup, Godspeed.

--config=/some/folder/rclone.config
(was Ole's advice)
And perhaps another tool created the config-dir... have no clue.

Considering, the .config directory was empty, it's pretty clear nothing else is using it.

rclone creates it during the config process if it doesn't exist.

perhaps rclone created the .config dir but was unable to create the rclone subdir in it.
Sounds strange to me.

It's not really rclone though as it's Linux/MacOS permissions.

If you ran something as root and pointed to your local user, you'd get a ".config" owned by root in that user's directory.

That will then create a permissions issue for anything else using that .config location as it can't write there.

The problem 'appears' as rclone but it's a permissions issue caused by something else you've done to create it.

As to what you've done, you've already shared, you don't have a clue so it really moot trying to guess other than a mistake was made that caused the issue and you've resolved it by either fixing the permissions or changing the location of the file.

I believe this is because of the included rclone --version command in the install.sh. Running that as sudo will create the config directory as root if it doesn't exist resulting in this issue.

To test it out, I removed my ~/.config/rclone directory and then ran sudo rclone --version resulting in

drwxr-xr-x     - root        staff 28 Oct 02:54  rclone

Did you do something different?

etexter@Earls-Mac-mini ~ % rm -rf .config
etexter@Earls-Mac-mini ~ % sudo -v ; curl https://rclone.org/install.sh | sudo bash
Password:
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  4669  100  4669    0     0  12730      0 --:--:-- --:--:-- --:--:-- 12791

The latest version of rclone rclone v1.60.0 is already installed.

etexter@Earls-Mac-mini ~ % ls -al | grep .config
etexter@Earls-Mac-mini ~ % cd .config
cd: no such file or directory: .config

I'm not seeing that.

And running rclone config creates it:

etexter@Earls-Mac-mini ~ % rclone config
2022/10/27 17:44:35 NOTICE: Config file "/Users/etexter/.config/rclone/rclone.conf" not found - using defaults
No remotes found, make a new one?
n) New remote
s) Set configuration password
q) Quit config
n/s/q> q
etexter@Earls-Mac-mini ~ % ls -al | grep .config
drwxr-xr-x@  3 etexter  staff     96 Oct 27 17:44 .config

You didn't do a fresh install indicated by:

The latest version of rclone rclone v1.60.0 is already installed.

A fresh install runs rclone --version at the end, which creates the .config directory.

I just rebuilt my Mac with Ventura release and did a fresh install.

I’ll clean all out and reshow once I get home later.

I meant the install script needs to actually install the rclone binary (it shouldn't have existed previously) while the .config folder is absent to reproduce the issue.

Acutally, you don't even need to run the install script, just remove the .config folder and run sudo rclone --version to see the folder created with root permissions. That's what the install script does anyway in the final lines:

#update version variable post install
version=$(rclone --version 2>>errors | head -n 1)

printf "\n${version} has successfully installed."
printf '\nNow run "rclone config" for setup. Check https://rclone.org/docs/ for more details.\n\n'
exit 0

I guess the question is why didn't it make the .config in root's home directory if it was running as sudo rather that the user's?

What does (as a user)

sudo rclone config file

Say?

As expected, it's my regular .config directory: /Users/darthshadow/.config/rclone/rclone.conf

Searching online indicated that this is because env_keep (from /etc/sudoers) retains the HOME environment variable while calling sudo:

Defaults  env_keep += "HOME MAIL"

Looks like this was the case for Ubuntu too, until 19.10:

The solution seems to be to use sudo -H, which works fine on Mac and on Ubuntu 18.04 too:

Configuration file doesn't exist, but rclone will use this path:
/var/root/.config/rclone/rclone.conf
Configuration file doesn't exist, but rclone will use this path:
/root/.config/rclone/rclone.conf

Perhaps the install docs need to be updated to use that instead?

I've removed everything, re-ran the install and I do not see a .config created when I installed.

I am 100% positive on this as I just installed my box fresh on Tuesday and had no issues reseting up a new config as I tested something for a SFTP post.

I downloaded the install.sh and added +x to it for the output.

sudo ./install.sh
+ set -e
+ unzip_tools_list=('unzip' '7z' 'busybox')
+ '[' -n '' ']'
+ '[' -n '' ']'
++ mktemp -d
+ tmp_dir=/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/tmp.sHc1ZPST
+ cd /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/tmp.sHc1ZPST
+ set +e
+ for tool in '${unzip_tools_list[*]}'
++ hash unzip
+ trash=
+ '[' 0 -eq 0 ']'
+ unzip_tool=unzip
+ break
+ set -e
+ '[' -z unzip ']'
+ export XDG_CONFIG_HOME=config
+ XDG_CONFIG_HOME=config
++ rclone --version
++ head -n 1
+ version=
+ '[' -z '' ']'
++ curl -fsS https://downloads.rclone.org/version.txt
+ current_version='rclone v1.60.0'
+ '[' '' = 'rclone v1.60.0' ']'
++ uname
+ OS=Darwin
+ case $OS in
+ OS=osx
+ binTgtDir=/usr/local/bin
+ man1TgtDir=/usr/local/share/man/man1
++ uname -m
+ OS_type=arm64
+ case "$OS_type" in
+ OS_type=arm64
+ '[' -z '' ']'
+ download_link=https://downloads.rclone.org/rclone-current-osx-arm64.zip
+ rclone_zip=rclone-current-osx-arm64.zip
+ curl -OfsS https://downloads.rclone.org/rclone-current-osx-arm64.zip
l+ unzip_dir=tmp_unzip_dir_for_rclone
+ case "$unzip_tool" in
+ unzip -a rclone-current-osx-arm64.zip -d tmp_unzip_dir_for_rclone
Archive:  rclone-current-osx-arm64.zip
   creating: tmp_unzip_dir_for_rclone/rclone-v1.60.0-osx-arm64/
  inflating: tmp_unzip_dir_for_rclone/rclone-v1.60.0-osx-arm64/git-log.txt  [text]
  inflating: tmp_unzip_dir_for_rclone/rclone-v1.60.0-osx-arm64/rclone  [binary]^R

  inflating: tmp_unzip_dir_for_rclone/rclone-v1.60.0-osx-arm64/rclone.1  [text]
  inflating: tmp_unzip_dir_for_rclone/rclone-v1.60.0-osx-arm64/README.html  [text]
  inflating: tmp_unzip_dir_for_rclone/rclone-v1.60.0-osx-arm64/README.txt  [text]
+ cd tmp_unzip_dir_for_rclone/rclone-v1.60.0-osx-arm64
+ case "$OS" in
+ mkdir -m 0555 -p /usr/local/bin
+ cp rclone /usr/local/bin/rclone.new
+ mv /usr/local/bin/rclone.new /usr/local/bin/rclone
+ chmod a=x /usr/local/bin/rclone
+ mkdir -m 0555 -p /usr/local/share/man/man1
+ cp rclone.1 /usr/local/share/man/man1
+ chmod a=r /usr/local/share/man/man1/rclone.1
++ rclone --version
++ head -n 1
+ version='rclone v1.60.0'
+ printf '\nrclone v1.60.0 has successfully installed.'

rclone v1.60.0 has successfully installed.+ printf '\nNow run "rclone config" for setup. Check https://rclone.org/docs/ for more details.\n\n'

Now run "rclone config" for setup. Check https://rclone.org/docs/ for more details.

+ exit 0

At the end, I do not see a .config made at all.

etexter@Earls-Mac-mini ~ % ls -al | grep .config

but

etexter@Earls-Mac-mini ~ % sudo rclone --version -vv
2022/10/27 20:21:09 DEBUG : rclone: Version "v1.60.0" starting with parameters ["rclone" "--version" "-vv"]
rclone v1.60.0
- os/version: darwin 13.0 (64 bit)
- os/kernel: 22.1.0 (arm64)
- os/type: darwin
- os/arch: arm64
- go/version: go1.19.2
- go/linking: dynamic
- go/tags: cmount
etexter@Earls-Mac-mini ~ % ls -al | grep .config
drwxr-xr-x@  3 root     staff     96 Oct 27 20:21 .config

does create it.

So the use case:

  1. install fresh
  2. run rclone "something" as sudo
  3. that creates the .config issue

So the OP ran the first config as root via sudo I'd imagine as that's the issue.

etexter@Earls-Mac-mini ~ % sudo rclone config
2022/10/27 20:22:26 NOTICE: Config file "/Users/etexter/.config/rclone/rclone.conf" not found - using defaults

and output:

This value is required and it has no default.
n/s/q> q
etexter@Earls-Mac-mini ~ % ls -al | grep .config
drwxr-xr-x@  3 root     staff     96 Oct 27 20:22 .config

I'm unsure how you'd fix that offhand.

Perhaps silly, but why crreate a .config/rclone/rclone.config outside the folder where rclone was installed in the first place

Not at all, good question.

The reason is that some prefer to copy rcone into their programs folder (/usr/local/bin on darwin) where only admin/root has write access. This way you don't have to use it like ./rclone, but can just write rclone (everywhere).

This is also the way the rclone script installation does it (executed with sudo):

Personally I also like to place rclone and the config together in the same folder. Once you have created it there using --config, then rclone will automatically find it without --config:

The complete logic is as follows: Rclone will look for an existing configuration file in any of the following locations, in priority order:

  1. rclone.conf (in program directory, where rclone executable is)
  2. %APPDATA%/rclone/rclone.conf (only on Windows)
  3. $XDG_CONFIG_HOME/rclone/rclone.conf (on all systems, including Windows)
  4. ~/.config/rclone/rclone.conf (see below for explanation of ~ symbol)
  5. ~/.rclone.conf

Source: https://rclone.org/docs/#config-config-file

Yep, looks like I was wrong. The XDG_CONFIG_HOME=config line, which prevents this issue, was added specifically to handle this root-owned config folder scenario: install.sh creates .config/rclone directory owned by root · Issue #2127 · rclone/rclone · GitHub

Man, this was a super fun one to fully understand and learned like 3 new things out of it so I'm happy you continued the questions as I feel pretty good we figured out the how/why of this one completely!

The timing was just funny as Ventura just released and I always just do a full wipe/reinstall as I hate upgrades :slight_smile:

I had not done a 'fresh' install in forever.

@Marcelloh - did you run the install or just download it?

The pattern would be you ran the install or download the binary and did something like

sudo ./rclone which would make the .config owned by root and thus break things from that point on instead of doing rclone as the user. Does that ring a bell?

I might have run sudo while running it for the first time. (downloaded and run)
But perhaps there should be a warning when the config dir does not exist at that moment