Building fails on remote with error Missing SConscript ''

I installed the pio remote agent successful on a raspberry.
But remote uploading a firmware fails while building on the remote:

warning: Calling missing SConscript without error is deprecated.
Transition by adding must_exist=False to SConscript calls.
Missing SConscript ''
File "/home/pi/.platformio/penv/lib/python3.9/site-packages/platformio/builder/", line 186, in <module>
*** [upload] Source `.pio/build/usb/firmware.bin' not found, needed by target `upload'.
========================== [FAILED] Took 4.15 seconds ==========================

I am using a custom referenced in platformio.ini:
extra_scripts =

The resides in the root directory of the project.

I solved this by moving the script from root to /src folder of project. This way it works.