Faster Mac OS X 10.10 Yosemite Upgrades for Developers

Photo Credit: National Park Service (USA)

Faster Mac OS X 10.10 Yosemite Upgrades for Developers

Your Yosemite upgrade may take many hours if you’ve got anything non-Apple in your /usr folder (Homebrew for example).

If you only develop Mac and iOS apps using Xcode, you are likely are not affected.

Symptoms

The Yosemite installer estimated times will be inaccurate. Part of the upgrade involves moving /usr/local out of the way. The process of moving those files back after the upgrade is done one file at a time and seems very slow.

If your installer seems stuck you can hit command-L to bring up the install log to assure yourself it’s actually running.

My initial Yosemite install took more than eight hours to complete, all the while stating “3 minutes remaining”. My other installs, with either of the recommended options below, took less than one hour each.

Not In a Rush? Run It Overnight

Just start your update before bedtime instead of during your work day. Problem solved.

Option 1: The Quick Fix

Recommended if you are comfortable on the command line. Suggested by @BruceHoult.

  1. Take a complete backup.

  2. Move /usr/local out of the way, before the install: sudo mv /usr/local ~/local

  3. Upgrade to Yosemite.

  4. After upgrade, move /usr/local back: sudo mv ~/local /usr/

If you are warned that /usr/local already exists, some service has created it on your behalf to store pids or logs. You will be warned that the target is not empty and the mv will fail.

If you are sure you want remove the auto-generated /usr/local and replace it with your own, you must remove the newly created /usr/local and copy your ~/local into place. If this paragraph sounds scary, then use option 2 instead.

If your /usr/local is back in place, and Homebrew is not compiling new installs or package upgrades correctly now, likely you need a Homebrew and Xcode update and it was not this guide that messed up your install. Run brew update; brew doctor and see what it recommends.

Option 2: In Place Cleanup

Recommended if you are comfortable with Homebrew and any language package managers you use, but somehow not comfortable with mv.

This is written from the perspective of a Homebrew and Ruby user. Still, it should give a sense of what to do if you’re using other tools. The steps below mostly revolve around removing unneeded stuff to speed up the post-upgrade /usr/local restore process.

  1. Take a complete backup or two.

  2. Run brew doctor and brew missing, make sure your Homebrew install is in good shape before you try cleaning it up or upgrading.

  3. Run brew leaves, which shows all your top level brew installs (brew list shows all including dependencies). If you see any that you don’t need any more, brew remove FORUMLA_NAME to remove all versions of it.

  4. run brew cleanup, this will remove unneeded and replaced packages, slimming down /usr/local.

  5. If you use Homebrew or some kind of version manager to install multiple versions of programming languages, remove unneeded older versions. For Ruby & rbenv with ruby-build plugin: rbenv versions lists what I’ve got installed and rbenv uninstall 1.9.3-p0 would remove a specific unwanted Ruby version.

  6. Advanced, read carefully. For programming languages with package managers that save into /usr/local, use the package manager’s cleanup command to remove older versions of packages. For Ruby, I’d switch to each installed version using rbenv and then run gem clean for each of them. Only do this if you have a mechanism in all of your projects to re-install missing dependencies. For Ruby, this means bundler. If you can’t know confidently that you can get back missing things don’t clean up in this manner. You will definitely end up having cleaned too much with this step. I wouldn’t recommend this except I got rid of a lot of cruft this way.

Please run brew doctor again to check the state of your Homebrew install before upgrading, so you know that it was working after this guide but before you start the upgrade to Yosemite.

If Homebrew does not work after your upgrade, try running brew update; brew doctor and see what it recommends.

In closing

Remember that command-L command exists to view install logs, or you may end up a very confused upgrader.

Comment on Hacker News