0

update: I found a workaround for this. Basically, creating a small file inside the Ubiquity folder kickstarts something in the bird daemon. YMMV, but anyone who wants to examine or try my script can download it from https://gist.github.com/luckman212/7afe50d37aa79d0170e8e96da2b96ae1

When I run brctl status | grep sync-up-scheduled | wc -l, it reports 136 files that are out of sync and need to be "synced up" to iCloud. They are referred to a Client Truth Unclean Items. Strangely, they all say attempts:0

brctl output

client truth unclean items

Both of my computers report this same number, and an identical set of files/folders. When I look in the iCloud SQLite database (~/Library/Application Support/CloudDocs/session/db/client.db), I can see that they are all refer to the Documents folders of various apps' Ubiquity Containers

I have tried the following:

  • Restarting the whole computer
  • Killing the bird daemon
  • Trashing the SQLite databases and session caches at:
    • ~/Library/Application Support/CloudDocs/session/db
    • ~/Library/Application Support/CloudDocs/session/containers
  • Trashing the entire contents of ~/Library/Mobile Documents/

This problem started exactly when I upgraded my 2 Macs to macOS Sonoma 14.0.

I have since tried updating one of them to 14.1 Developer Beta 2 to see if it was a bug that's been fixed, but that hasn't helped.

I have a paid iCloud account (200GB) and am currently using it to store about 55GB of data. Most of it is occupied by a replica of my Obsidian vault which consists of lots of small text (markdown) files and some PNGs. This data is synced fine, the issue appears to be with the hidden iCloud Sync data that apps use to sync with iCloud.

I have tested with Optimize Mac Storage both ON and OFF (it's currently OFF). Made no difference.

Here is a screenshot of my iCloud prefs:

screenshot of iCloud prefs

4
  • If you run it without the grep you should see the message >>> SYNC DISABLED (app not installed). Are you seeing this message for any installed apps or is anything visibly not syncing that you want to be syncing?
    – Ezekiel
    Commented Oct 6, 2023 at 21:37
  • @Ezekiel No, there are no messages like that anywhere in the output of brctl dump or brctl status. Everything seems to be syncing ok, but the message is messing up a monitoring script I have to report on iCloud sync problems. So I'd like to fix it.
    – luckman212
    Commented Oct 7, 2023 at 3:55
  • I have reviewed mine some more and see that some don't have that message. I found one example and opened up its iCloud folder to find 0 files. Error message: i.imgur.com/N2etfcu.png Folder contents: i.imgur.com/HDm0YtI.png
    – Ezekiel
    Commented Oct 8, 2023 at 13:16
  • @luckman212 Can you answer your own question here with your script and accept it? It worked for me.
    – Mattie
    Commented Nov 5, 2023 at 14:56

1 Answer 1

1

@Mattie suggested in a comment above that the script I mentioned worked for them as well, so we now have a sample size of 2. I am going to self-answer with that suggestion.

  1. save the script below as icloud_ubiquity_fix.sh
  2. make executable with chmod +x icloud_ubiquity_fix.sh and run it.
#!/usr/bin/env bash

CLIENT_DB="$HOME/Library/Application Support/CloudDocs/session/db/client.db"
[[ -e $CLIENT_DB ]] || { echo "db not found"; exit 1; }

mapfile -t ITEM_IDS < <(sqlite3 "$CLIENT_DB" <<-EOS
    SELECT throttle_id
    FROM client_sync_up
    EOS
)
STUCKITEMCOUNT=${#ITEM_IDS[@]}
(( STUCKITEMCOUNT > 0 )) || { echo "no stuck items found"; exit 0; }
echo "found ${STUCKITEMCOUNT} stuck items"
CANARY_FNAME="flag_$(xxd -l3 -ps -c0 /dev/urandom)"
ID_STR=$(IFS=,; echo "${ITEM_IDS[*]}")

while IFS='|' read -r LIBRARY_NAME FNAME SESS_DIR _ ; do
    FNAME=${FNAME/\~/$HOME}
    SESS_DIR=${SESS_DIR/\~/$HOME}
    if [[ -d $FNAME ]]; then
        echo "writing canary file to $FNAME"
        echo "xyzzy" >"$FNAME/$CANARY_FNAME"
    else
        echo "updating timestamp of $FNAME"
        touch -A "$FNAME"
    fi
    done < <(sqlite3 "$CLIENT_DB" <<-EOS
SELECT
    l.app_library_name,
    '~/Library/Mobile Documents/' || REPLACE(l.app_library_name, '.', '~') || '/' || ci.item_filename,
    '~/Library/Application Support/CloudDocs/session/containers/' || l.app_library_name
FROM
    client_items as ci
INNER JOIN
    app_libraries as l on ci.app_library_rowid = l.rowid
WHERE
    ci.rowid IN ( $ID_STR )
ORDER BY
    l.app_library_name
EOS
)

echo "pausing 10s to allow for stabilization"
sleep 10
echo "deleting flag/canary files ($CANARY_FNAME)"
find "$HOME/Library/Mobile Documents" -type f -name "$CANARY_FNAME" -delete

echo "done. please run \`brctl status\` again to re-check"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .