I have my Obsidian in iCloud like you and get the same issue. But I figured out why: the problem is that the json file is not always synchronized, meaning it is in the cloud but not on your computer. You have to click on it on the Finder and download it, then you can try to update your repository in Obsidian. In my case, it works.
I wonder if a solution would be to place the vault outside iCloud, but then you would it only local.
I don’t know about ways to “tell” iCloud to leave folders always on you computer. I guess this is one of the big pitfalls of iCloud.