Updating my Nexus 4

cd /Users/raystuckey/Downloads/occam-krt16o

reboot the phone into recovery

adb reboot bootloader

edit flash-all.sh and remove the -w and it won't wipe the device

raystuckey$ /Users/raystuckey/Downloads/occam-krt16o/flash-all.sh

let it reboot, then boot back into the bootloader

fastboot flash recovery /Users/raystuckey/Desktop/Desktop\ Folder/RootNexus4/openrecovery-twrp-

This used to work with Jelly Bean, but Lollipop has changed how to get root. See the section below.

Boot into recovery (twrp) and install superSU

adb push /Users/raystuckey/Desktop/Desktop\ Folder/RootNexus4/UPDATE-SuperSU-v1.69.zip sdcard/UPDATE-SuperSU-v1.69.zip

For Lollipop:
reboot the phone into recovery
adb reboot bootloader

Use CF-autoroot from Chainfire. Unzip and run. Might need to chmod +x root-mac.sh


I've had a problem on OSX where it get the error message:
fastboot(22763,0xa069c1d4) malloc: *** mach_vm_map(size=1787752448) failed (error code=3)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
failed to allocate 1785963604 bytes
error: update package missing system.img

See details here for how to work around it.