Restore libxml2 to Yosemite Ok, so here is the deal. I was working on two projects at the same time and I mistakenly:

rm -rf /usr/lib/libxml2.2.dylib


I have another copy of libxml2 thankfully (the other project, homebrew install libxml2). That copy is in /usr/local/opt/libxml/lib. For the life of me I can not get cp /usr/local/opt/libxml2/lib/libxml2.2.dylib /usr/lib to work. It always says:

/usr/lib/libxml2.2.dylib Read-only Filesystem


Please can anyone help? I have tried cp -S, -R, -F and I can't get it to cp or mv. I just need to write that lib back and I should be good to go. I don't know what I was thinking when I did that. Running Yosemite 10.10.2, Late-2011 mbp. Libxml2 from homebrew is 2.9.2 I think if it makes a difference.
Enter /sbin/mount -uw / and copy 'libxml2.2.dylib' from '/usr/local/opt/libxml/lib/' to '/usr/lib/'

Restart your Mac and restore the original file:

Download Pacifist (i think it's a 14-day trial) and the Yosemite System Installer

Right-click the 'Install OS X Yosemite.app' -&gt; 'Show Package Contents'

Mount ./Contents/SharedSupport/InstallESD.dmg


Open the mounted 'OS X Install ESD'

Open ./Packages/BaseSystemBinaries.pkg with Pacifist

In the new Pacifist-window navigate to 'Content of BaseSystemBinaries/usr/lib/libxml2.2.dylib'

Right-click libxml2.2.dylib and install it

Restart your Mac