RCIONE config not working inside PHP file

Hello everyone, I'm facing a strange problem. I'm using RCLONE for Google Drive on a Windows 11 machine.

Rclone commands are working correctly in Comand Prompt. I can setup a new remote, list files, save files to drive etc.

But when I run the command in the PHP file, it shows this error

2023/11/01 20:33:28 DEBUG : rclone: Version "v1.58.0" starting with parameters ["rclone" "copyurl" "--checksum" "--progress" "-vv" "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf" "newrc:thisisyg/new_yg"]
2023/11/01 20:33:28 DEBUG : Creating backend with remote "newrc:thisisyg/"
2023/11/01 20:33:28 NOTICE: Config file "C:\\windows\\system32\\config\\systemprofile\\AppData\\Roaming\\rclone\\rclone.conf" not found - using defaults
2023/11/01 20:33:28 Failed to create file system for "newrc:thisisyg/": didn't find section in config file

And when I run rclone config command in Command Prompt it shows the remote name.

But the same command in the PHP file outputs this -

No remotes found, make a new one?
n) New remote
s) Set configuration password
q) Quit config
n/s/q> 

I can't understand what the problem is. Please help me out.

What

rclone config file

shows when you run it from cmd?

welcome to the forum,

looks like you are running PHP as system user.
perhaps you did testing as a standard user?

need to specify the location of the rclone config file by adding
--config=/path/to/rclone.conf
or move the config file to the correct location inside system user profile

you can find the config file using
rclone config file
or search your file system for rclone.conf

where /r c:\ rclone.conf

fwiw, test on command line first.

When I run this command in Comand Prompt it shows this -

C:\xampp\htdocs\yadavg\rclone>rclone config file
Configuration file is stored at:
C:\Users\Friends\AppData\Roaming\rclone\rclone.conf

When I run whoami in Command Prompt it shows this -

C:\xampp\htdocs\yadavg\rclone>whoami
laptop-c6b5h0be\friends

in this PHP file, it return this -

nt authority\system

So now all is working?

No, it still not working and I didn't do anything.

Actually, I couldn't understand any solutions given here. asdffdsa's answer suggests I move the config file to the correct location.

But I don't know what is the correct location. :roll_eyes:

Used config location is derived from user (whoami tells you which one it is) running rclone.

When you run it from cmd as user friends rclone uses:

But when you run it from PHP script it is executed as user system and rclone uses:

But nothing is there....

There are two options to fix it as @asdffdsa explained:

  1. Put rclone config in C:\windows\system32\config\systemprofile\AppData\Roaming\rclone

  2. Use always Friends' user config. You can achieve it by adding --config flag to your PHP rclone command - it tells rclone which config file to use explicitly:

rclone copyurl --checksum --progress -vv https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf newrc:thisisyg/new_yg --config C:\Users\Friends\AppData\Roaming\rclone\rclone.conf

IMO option 2 is better as you avoid maintaining two different rclone.conf files.

And here you can find more details about rclone.conf behaviour.

1 Like

each windows user has it own user profile.
for Friends = C:\Users\Friends
for system = C:\WINDOWS\system32\config\systemprofile

the rclone.conf file is stored in the same location, relative to the root of the user profile.
%APPDATA%/rclone/rclone.conf

best easy solution, have one config file shared by both users.
so for the php command, hardcode the location using
--config=C:\Users\Friends\AppData\Roaming\rclone\rclone.conf

thank you very much :heart:, It's working now.

I was stuck in this for a long time.

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