{"id":18707,"date":"2018-07-02T16:46:20","date_gmt":"2018-07-02T20:46:20","guid":{"rendered":"https:\/\/nuxx.net\/blog\/?p=18707"},"modified":"2018-07-02T16:46:20","modified_gmt":"2018-07-02T20:46:20","slug":"defaults-on-macos-can-break-otherwise-usable-plist-files","status":"publish","type":"post","link":"https:\/\/nuxx.net\/blog\/2018\/07\/02\/defaults-on-macos-can-break-otherwise-usable-plist-files\/","title":{"rendered":"defaults on macOS Can Break Otherwise Usable plist Files"},"content":{"rendered":"<p>Today I learned that the <code>defaults(1)<\/code> command on macOS can break otherwise-parsable <a href=\"https:\/\/en.wikipedia.org\/wiki\/Property_list\">plist<\/a> files.<\/p>\n<p>I found this when trying to change <code>selectedThrottleIndex<\/code>\u00a0in the <a href=\"https:\/\/www.arqbackup.com\/\">Arq<\/a> config (<code>~\/Library\/Arq\/config\/app_config.plist<\/code>) to adjust a bandwidth usage setting. I didn&#8217;t have access to the GUI, wanted to change things from CLI, and whoops! After changing this things broke.<\/p>\n<p>Consider this&#8230; First I read out the setting with\u00a0<code>defaults read ~\/Library\/Arq\/config\/app_config.plist selectedThrottleIndex<\/code>, then set it with\u00a0<code>defaults write ~\/Library\/Arq\/config\/app_config.plist selectedThrottleIndex 2<\/code>, then read it again to verify the change. All looked good, so I figured I was done and I let things bake.<\/p>\n<p>Upon getting physical access to the machine and launching the GUI, I found that Arq was no longer activated, needed my license info again, and then (uggh!) had lost my configuration. This was fixed by first restoring the whole of\u00a0<code>~\/Library\/Arq<\/code> from <a href=\"https:\/\/en.wikipedia.org\/wiki\/Time_Machine_(macOS)\">Time Machine<\/a>, launching Arq, browsing to the backup destination, and clearing it&#8217;s cache. After rescanning the destination all was good.<\/p>\n<p>So, why did it happen? Well, it turns out that Arq uses a headerless XML-ish text file with the suffix <code>.plist<\/code>. Even though it&#8217;s not in the same format as <code>plutil(1)<\/code> outputs, <code>defaults(1)<\/code> will still read it and modify it&#8230; But the resulting file is a plist binary! It seems that Arq only likes to parse its format (note: I did not exhaustively test this &#8212; <code>plutil(1)<\/code>&#8216;s <code>xml1<\/code> format <em>may<\/em> work), so upon seeing the binary version it the program presumed no config and started over. Whoops! Interestingly, the <code>defaults(1)<\/code>, <code>plutil(1)<\/code>, and <code>pl(1)<\/code> commands will all happily parse the Arq format file.<\/p>\n<p>Note that after launching Arq with the broken config and re-adding the license, restoring just the <code>app_config.plist<\/code> file didn&#8217;t make things better, which is why I jumped right to restoring the whole <code>~\/Library\/Arq<\/code> directory. There must be some config caching somewhere or so&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I learned that the defaults(1) command on macOS can break otherwise-parsable plist files. I found this when trying to change selectedThrottleIndex\u00a0in the Arq config&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/nuxx.net\/blog\/2018\/07\/02\/defaults-on-macos-can-break-otherwise-usable-plist-files\/\">Continue reading<span class=\"screen-reader-text\">defaults on macOS Can Break Otherwise Usable plist Files<\/span><\/a><\/div>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-18707","post","type-post","status-publish","format-standard","hentry","category-computers","entry"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/posts\/18707","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/comments?post=18707"}],"version-history":[{"count":2,"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/posts\/18707\/revisions"}],"predecessor-version":[{"id":18709,"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/posts\/18707\/revisions\/18709"}],"wp:attachment":[{"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/media?parent=18707"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/categories?post=18707"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/tags?post=18707"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}