defaults-read

I've tried using "defaults read" and got strange error messages that looked like this:

 $ defaults read > defaults.out
 ccyy-mm-dd hh:mm:ss.sss defaults[####:###] Preference plist was NOT a dictionary.

I did some searching on the Web and found this article: "Preference plist was NOT a dictionary".

Kevinwal, Jockey and others, supplied the solution which, when pieced together, looks like this:

From Terminal.app, look for offending plists in two places.

"cd" to the appropriate place, choosing either of these:

 cd /Library/Preferences
 cd ~/Library/Preferences

These are similar, but one is your private ~/Library, and the

other is the system's /Library. I recommend you start with your

private ~/Library. Scan within that Library with this command:

 egrep -H '^<array>' *.plist

If there are no hits, try the other Library directory, or quit.

If you find hits, those are the offending plists in this directory, but if they belong to "root", ignore them.

Some may be "binary". You can convert them to character format with this command:

 plutil -convert xml1 offending.plist

Do that for each offending "binary" plist you have found.

For each offending plist, you have several choices:

1) You can "remove" it with "rm -f offending.plist". However,

if whatever created it recreates it, it may end up offending again.

2) You can "edit" it with the "Property List Editor". Be sure to only

change top level instances of <array> and </array> into <dict> and

</dict>. Do NOT change array-statements that are nested inside other

statements.

3) You can use "sed" to replace top-level <array> and </array>, like this:

 cat offending.plist | sed '1,$s;^<array>;<dict>;' | sed '1,$s;^</array>;</dict>;' >/tmp/offending.plist

You want to put the result in /tmp just to be sure you haven't destroyed

the original file. Then check it as follows:

 diff offending.plist /tmp/offending.plist

You should only see top-level changes of <array> and </array> into

<dict> and </dict>. If so, then you can replace your original

offending.plist like this:

 cat /tmp/offending.plist >offending.plist

Do whichever method is appropriate for every plist that needs to be fixed.

I used method 3 for all my offending plists, and now everything works fine.

If necessary, repeat this entire procedure from "egrep" with the other Library.