{"id":3049,"date":"2014-01-30T15:18:21","date_gmt":"2014-01-30T23:18:21","guid":{"rendered":"http:\/\/manytricks.com\/blog\/?p=3049"},"modified":"2014-11-13T09:18:20","modified_gmt":"2014-11-13T17:18:20","slug":"how-to-replace-preference-files-in-mavericks","status":"publish","type":"post","link":"https:\/\/manytricks.com\/blog\/?p=3049","title":{"rendered":"How-to: Replace preference files in Mavericks"},"content":{"rendered":"<p><!--RGSupportContent-->Something many people do, myself included, is copy an application&#8217;s preferences file&mdash;either from one Mac to another (as a quick way of getting an app configured to my liking) or to replace a damaged\/lost preferences file using a Time Machine backup. Until recently, this process was really simple: quit the app in question, trash the existing prefs file, insert the new prefs file, launch app.<\/p>\n<p>Enter OS X 10.9, aka Mavericks, aka &#8220;the easy prefs copy killer.&#8221; Apple has made changes to the way the preferences system works in Mavericks, and one casualty of those changes is the easy replacement of an application&#8217;s preferences file. A brief bit of before-and-after, and then we&#8217;ll get to the fix&mdash;or just click the Read More link to jump right to the fix.<\/p>\n<p>In prior versions of OS X, preferences files were always read by the application at launch. So as long as the app wasn&#8217;t running, if you replaced its preference file, it would read the new file the next time you launched the program.<\/p>\n<p>In Mavericks, preferences are <a href=\"http:\/\/hints.macworld.com\/article.php?story=20130908042828630\">managed by a background daemon<\/a>, <a href=\"https:\/\/developer.apple.com\/library\/mac\/documentation\/Darwin\/Reference\/ManPages\/man8\/cfprefsd.8.html\"><span style=\"font-family:monospace\">cfprefsd<\/span><\/a>. This service reads the preferences file once, when you first run the app. It then (I believe) receives notifications if you change the program&#8217;s settings while the program is running, and then writes them to the actual preferences file at certain points in time. But <tt>cfprefsd<\/tt> always has a copy of those settings in its cache, and that&#8217;s what the app gets when it checks its settings. (This reduces hard disk access, which is important in conserving battery life in laptops.)<\/p>\n<p>Here&#8217;s the important bit: After you&#8217;ve launched an app once, it seems that any subsequent launches also get their preferences from <tt>cfprefsd<\/tt>. So if you try the old &#8220;replace the prefs while the app isn&#8217;t running&#8221; trick, you&#8217;ll be quite surprised to find that your program launches with its previous settings. It will do this even if you simply delete (via Finder) the old prefs file!<\/p>\n<p>So how do you get around this aggressive caching of preference files?<\/p>\n<p><!--more--><\/p>\n<p>I&#8217;m aware of two solutions, though there may be others (please comment, if you know of a better way).<\/p>\n<hr>\n<p><b>Update based on comments:<\/b> The best solution, per the comments below, is to quit the app, open Terminal, paste <tt>killall cfprefsd<\/tt> then press Return. This relaunches the prefs system; now relaunch the app, and it should read the modified prefs file.<\/p>\n<hr>\n<h3>Method One:<\/h2>\n<ol>\n<li>Quit the app, and make sure it is <em>not<\/em> set to run at login.<\/li>\n<li>Delete the app&#8217;s prefs file (typically in ~\/Library\/Preferences, for non-sandboxed applications).<\/li>\n<li>Logout.<\/li>\n<li>Login.<\/li>\n<li>Copy the prefs file you want to use into its home.<\/li>\n<li>Launch the app.<\/li>\n<\/ol>\n<h3>Method Two:<\/h2>\n<ol>\n<li>Quit the app, leaving the &#8216;bad&#8217; prefs file in place.<\/li>\n<li>Open Terminal, paste the following, and press Return: <tt>defaults delete com.COMPANY_ID.APP_ID<\/tt>. Note that <tt>COMPANY_ID<\/tt> and <tt>APP_ID<\/tt> are taken from the name of the app&#8217;s preferences file. Using our own <a href=\"\/moom\">Moom<\/a> for example, the preferences file is named <tt>com.manytricks.Moom.plist<\/tt>, so the command would be <tt>defaults delete com.manytricks.Moom<\/tt>.<\/li>\n<li>Copy the prefs file you want to use into the ~\/Library\/Preferences folder.<\/li>\n<li>Launch the app.<\/li>\n<p>I&#8217;ve tested both of these methods and found them to work, but would love to discover there&#8217;s an easier solution. <\/p>\n<p>Net net, if you want to replace prefs files in Mavericks, it&#8217;s now more complicated than it used to be&hellip;but it is still possible.<!--\/RGSupportContent--><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Something many people do, myself included, is copy an application&#8217;s preferences file&mdash;either from one Mac to another (as a quick way of getting an app configured to my liking) or to replace a damaged\/lost preferences file using a Time Machine backup. Until recently, this process was really simple: quit the app in question, trash the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[5,11,26,29,6,28,7,4,25,24,8],"tags":[],"coauthors":[21],"class_list":["post-3049","post","type-post","status-publish","format-standard","hentry","category-butler","category-desktop-curtain","category-how-to","category-keymo","category-leech","category-moom","category-name-mangler","category-products","category-time-sink","category-usher","category-witch"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/manytricks.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3049","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/manytricks.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/manytricks.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/manytricks.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/manytricks.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3049"}],"version-history":[{"count":9,"href":"https:\/\/manytricks.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3049\/revisions"}],"predecessor-version":[{"id":3236,"href":"https:\/\/manytricks.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3049\/revisions\/3236"}],"wp:attachment":[{"href":"https:\/\/manytricks.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3049"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/manytricks.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3049"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/manytricks.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3049"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/manytricks.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcoauthors&post=3049"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}