Repair disk permissions on OSX

We've all (I hope) encountered issues where dependencies were installed as superuser using bower, ruby gems or npm.

This can be a pain, and a quick solution is often to do a recursive chown and chmod at the appropriate '/lib' directory. The issue is that if you apply this at the wrong level, you'll cause yourself a world of hurt.

A while ago, I managed to lock myself out of terminal, with only the following message displaying upon opening a new shell:

Last login: Tue Mar 11 14:33:24 on console login(291,0x7fff78af9310) malloc: * error for object 0x7f974be006f0: pointer being freed was not allocated * set a breakpoint in malloc_error_break to debug

[Process completed]

Fortunately, there's a quick-and-easy solution for this:

  1. Delete from the ~/Library/Preference folder;
  2. Open "Disk Utility" app -> Press "Repair Disk Permissions".