Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

johncandyismyuncle

macrumors newbie
Original poster
Oct 24, 2019
2
0
Hey Guys,

New member here. Posted specifically for this. Today I shot myself in the foot. I replaced a file in my "/usr/lib" folder and then restarted my laptop. Now my laptop won't turn on.

I'm running an older version of Mojave, 10.4 maybe? (can't check right now because my laptop is unusable)

The file I replaced was called "libstdc++.6.0.0." and I had accessed its folder via typing in "csrutil disable" in my terminal as my laptop wouldn't let me replace the above file by simply dragging and dropping it in there like you normally would do to move a file (should have taken that as a warning sign...)

Anyway, I can only use my laptop by booting it and holding cmd+R and from there I can access my terminal, recovery etc. However I really don't want to format my mac if possible...

Right now, I've managed to hook my MacBook up to my roommates MacBook pro running OS Hi Sierra via Target Disk Mode & a thunderbolt cable.

I managed to get into my laptops bricked hard drive, and could even navigate my way to MY "/usr/lib" folder (via terminal commands) and see the NEW "libstdc++.6.0.0." file that I had moved in there that caused this whole mess in the first place!! But it won't let me drag it out and put the correct ORIGINAL file in!! It gives me a sign that looks like this "?" and says I don't have access to edit the files in this folder (same msg I got on my laptop which is why i overrode it in terminal via typing in "csrutil disable").

I have my MacBooks original "libstdc++.6.0.0" file (the one that I should never have removed) in a folder on MY MacBooks desktop, and via Target Disk Mode I've also been able to transfer it onto a USB stick. Its the only file on this USB as well.

I am wondering if I can somehow put the ORIGINAL "libstdc++.6.0.0" file back into my "/usr/lib" folder via Target Disk Mode.

I tried to drag and drop it back into my MacBooks "/usr/lib" folder via the Target Disk Mode and utilizing the terminal to direct me to the folder in the first place (you can't find it without using terminal), but it told me I didn't have permission to edit the folder because I'm accessing my MacBook (Running Mojave) through my roommates older MacBook Pro (running OS Hi Sierra) and it is telling me that in order to edit the file, I would have to type that same: "csrutil disable" into my roommates MacBooks terminal during recovery mode. (same thing I mentioned up above, the "?" appears).

It seems like if I put my roommates MacBook into recovery mode, open terminal and type in the "csrutil disable" prompt I may be able to set things straight. I just REALLY don't wanna ruin his laptop too.. so I'm coming here with my problem in hopes that someone may be able to weigh in on this ridiculous situation (I am backing my effing laptop up if i ever make it through this).

I know this all sounds super goddamn confusing, believe me I have been scratching my head all day. I have so many projects on my current MacBook I really really really do not wanna have to wipe it down and start all over. PLEASE if anyone knows how to deal with this I would love their help!

Cheers!!
 
Last edited:

casperes1996

macrumors 604
Jan 26, 2014
7,492
5,661
Horsens, Denmark
Why were you replacing your C++ standard library in the first place?

The simplest solution is to extract all your data through the target disk mode access and wipe it when you've saved what you want saved.

If you want to attempt to restore the library file, I don't think you even need to bother with target disk mode. Reboot into the recovery mode, mount the USB drive and your main volume, and use mv to move the file over all on your own device
 

johncandyismyuncle

macrumors newbie
Original poster
Oct 24, 2019
2
0
I really appreciate your response!

I was attempting to get an older version of an audio plugin working in Logic Pro X. I definitely think I could salvage a back up of my files but they would still have the messed up "libstdc++.6.0.0" file and I really don't want to lose any of my music projects.

Any other way to do this without completely wiping my mac and attempting to restore a (potentially) damaged back up?
 

casperes1996

macrumors 604
Jan 26, 2014
7,492
5,661
Horsens, Denmark
I really appreciate your response!

I was attempting to get an older version of an audio plugin working in Logic Pro X. I definitely think I could salvage a back up of my files but they would still have the messed up "libstdc++.6.0.0" file and I really don't want to lose any of my music projects.

Any other way to do this without completely wiping my mac and attempting to restore a (potentially) damaged back up?

Well what I was suggesting was to just pull your user folder, reinstall macOS, and Bring back what you need, which would then not include the C++ library.

But as mentioned, you can use the mv command to move a file from Terminal, so you could from your own machine try and move the file from your Usb drive to your disk through the Recovery Terminal (I've never actually attempted to work on the file system from recovery mode, but I imagine you can just mount your disk and navigate to it)
 

Octopuss

macrumors regular
Oct 18, 2017
154
215
Very likely you will end up wiping your disk and reinstalling OS.
In any case, before any further experiments, backup your user folder! You will need it if you completely brick your laptop or after OS reinstall.

You may keep experimenting on broken system for couple days and make things worse or recover it, former more likely (I have wide experience in ruining things after similar experiments). Alternatively you can accept that it's gone and backup\reinstall everything in few hours.

In future, to run any old/incompatible software use virtualization: VirtualBox, VMWare or even better cloud desktop services.
 
Last edited:

mick2

macrumors 6502
Oct 5, 2017
251
237
UK
Is there not some sort of 'repair MacOS' option after booting to the repair console? Don't have a Mac on hand to check this myself.
As @casperes1996 said, in general terms, the quickest way is to
- boot to a recovery console
- disable SIP: csrutil disable
- login as root (this might be by default in the recovery console)
- mnt both your USB and Macintosh HD volumes so they're accessible in the recovery console
- cp the original libstdc to its original location. Check the permissions on this are also correct after moving - compare with permissions on your friends' Macbook, then chmod / chown as nec.
- when working, reenable SIP: csrutil enable
You might have some extra permissions / security / csrutil hoops to jump through when doing this because Apple, but these are the basic steps. If you're not comfortable with *nix command stuff then anyone who uses Linux / BSD etc could help with this.
 
Last edited:

me55

macrumors regular
Jul 26, 2019
130
58
You could just try reinstalling macOS, cmd+R and selecting "Install macOS" or whatever the menu point name is. Unless you format the disk there is no data being deleted, but I'd still make sure you have a current backup.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.