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, Texlive, or Mactex for example). If you got here by googling for “Yosemite install stuck” or “one minute remaining” it’s too late to speed it up… but don’t turn off your computer, let it finish.

This will only materially impact your speed if you’ve got hundreds of thousands of files in /usr/local, if you’ve only installed a few things into ‘/usr’, don’t worry. You can count the number of files by running find /usr/local | wc -l. I’ve heard feedback of pauses from 5 minutes to 12 hours.

Anything in /opt (like MacPorts) is not affected.

If you only develop Mac and iOS apps using Xcode, you are likely are not affected. If none of this makes any sense to you, then you definitely are not affected.

This isn’t Homebrew or other software doing anything wrong. Just that the Yosemite 10.10 installer does not expect to find anything significant in this folder. Mavericks 10.9 installer had similar issues with large /usr folders.

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. NOTE: If you’ve got a lot of files affected you may eventually get an error message about the log buffer being full. This error did not kill your upgrade, leave it 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. It must be moved totally out of /usr, that whole folder is affected by this slow upgrade process.

  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.

In that case you must merge your ~/local into the auto-generated /usr/local. The command should be something like sudo ditto -V ~/local /usr/local. This copies the files back into place, so it will take longer than just mv. Make sure to delete the folder ~/local after you confirm that ditto finished correctly .

If you use zsh or another alternate shell, you may have moved your shell binary out of your path. You can likely fix that by opening Terminal app Preferences and choosing the General tab, and setting Shells open with to Default login shell until you’ve moved /usr/local back into place.

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 FORMULA_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