2

At some point in the past I was messing around with the battery menu on my 2012 MacBook Pro running High Sierra to see if I could it to display the estimated time remaining rather than a percentage. Anywho, I created a copy of the file /System/Library/CoreServices/Menu Extras/Battery.menu which I no longer needed, so I trashed it.

Since then I have been unable to move the item from the trash or delete it.

I have tried:

  • deleting normally
  • using the force delete option (option + delete)
  • trying to drag item out of trash (makes a copy, which is deletable)
  • running sudo rm -vrf ~/.Trash/Battery.menu (result: "Operation not permitted")
  • renaming and moving the file with sudo mv ~/.Trash/Battery.menu (result: "Operation not permitted")
  • running the above commands after su in Terminal
  • using the root account to try the above
  • booting into single user mode, mounting the file system, using above commands. (result: "Operation not permitted")
  • using setfile to try to set the busy attribute to not busy and to unlock the file (though it is not locked) using setfile -a z ~/.Trash/Battery.menu. Result: "ERROR: Unexpected Error. (-5000) on file: /Users/myuser/.Trash/Battery.menu"
  • repairing permissions, then trying everything again
  • booting into recovery, turning off SIP, and trying to delete again.

Any ideas?

4 Answers 4

2

I recently had a file I could not delete from Trash. Finally I moved it from the Trash back to the Desktop, which I have synced to iCloud. Then I was able to use the Files app on my iPhone to delete it.

Another path to pursue: boot to recovery and turn off SIP (until you get the file deleted.)

2
  • It can't be moved from the trash, only copied. But I will try the second option about turning of SIP!
    – malkazeara
    Commented Jul 2, 2019 at 5:49
  • I tried turning off SIP but sadly I am still unable to delete that file. Thanks for the suggestion though.
    – malkazeara
    Commented Jul 2, 2019 at 12:19
0

Recovery to delete?

I see you booted into recovery to disable SIP, but did you attempt the delete from the terminal while in recovery mode? Any files that are not open/protected by the currently-running OS should be manageable.

0

I had this problem with a number of large macOS installers hogging valuable space, which would move to ~/.Trash and back but otherwise only copy and acquire this icon in the process:

crossed-out circle icon acquired by files and directories that can't be deleted

After losing most of my hair over the matter, I stumbled upon several answers that said to go to Recovery Mode (Command+R during bootup) and temporarily disable csrutil (System Integrity Protection or SIP).

(Helpful hint: take all your problematic files and put them in a folder with a super-unique name like xxxabc, and drag that folder to the Trash. You'll see why this is useful in a second.)

Was getting ready to disable the SIP, but before that, just for kicks, while in Recovery Mode, I opened up a Terminal window and searched for my user name (so I could then access ~/.Trash):

find / -iname '*mycurrentusernameinUsers*'

Once I located the specific path to my profile with the problematic indelible Trash contents, I changed to that directory using cd:

cd /Volumes/Macintosh\ HD/Users/mycurrentusernameinUsers

I'm now inside ~/.Trash (~ being a stand-in for mycurrentusernameinUsers AKA my home directory). Turns out that, while in Recovery Mode, I can rm -rf an undeletable folder here no problem.

As such, in bash, in Recovery Mode, this was the FINAL FIX, without having to disable the SIP:

rm -rf xxxabc

Full path:

rm -rf /Volumes/Macintosh\ HD/Users/mycurrentusernameinUsers/.Trash/xxxabc

(Your path may vary.)

-1

Why aren't you allowed to delete that file?

As you are getting the "Operation Not Permitted" message, I can tell that the file is protected by the system and is therefore extremely hard to delete through normal deletion means (as you have tried).

You could normally run sudo rm -rf Battery.menu to delete this file but as mentioned above, it won't work.

How to fix that error? (And delete the file)

To delete the unwanted file, run this command in Terminal :

sudo /System/Library/Extensions/TMSafetyNet.kext/Contents/Helpers/bypass rm -rfv Battery.menu

This will bypass every restriction that are in place causing it to show the error shown above ("Operation Not Permitted") when running sudo rm -rf Battery.menu.

Note that "bypass" is still located in /System/Library/Extensions/TMSafetyNet.kext/Contents/Helpers/bypass for me.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .