MacOS: trying to load evicted file from launch'd shell script, leading to resource deadlock error
On MacOS Sonoma (14.5) with iCloud synchronization switched on, I am trying to access or load a file in a (bash) shell script. Simply via:
cat DSC_0001.jpg >/dev/null
(Note that this simple line of code is for me the reproducible example. DSC_0001.jpg is just an example file, the problem described here appears for all files, as long as other conditions hold, as described below.)
This line of (shell) code works perfectly fine when I do this in a terminal, even if the file is "evicted" to iCloud.
As far as I understand, a file is "evicted" to iCloud when iCloud uploaded it to the cloud, but deleted the local copy, so that it is no longer physically stored on my machine, but on the cloud. In Finder, such files are marked with a cloud and arrow symbol.
I need to work with such evicted files, in a shell script that I run in the background, as a launch'd agent, via launchctl and a plist configuration file in ~/Library/LaunchAgents . (Note that ultimately, I want to backup the file and many others via rsync, not just cat the file as in the example above, but this one seems to be the simplest reproducible version of my problem.)
Now my problem is, that if the file is evicted, AND if I run the above command in a launch'd script, then the command throws the following error:
cat: DSC_0001.JPG: Resource deadlock avoided
How can I get rid of this error, and access or load the evicted file in my launch'd script?