Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

cannot completely empty trash in Mojave

Running macOS 10.14.3 on a 2015 MacBook Pro. Two items in the Trash which I can't empty. Finder errors (occur twice, for each of the 2 items) are:

The operation can’t be completed because the item “Data” is in use. [Skip] [Stop] [Continue]

The operation can’t be completed because the item “com.apple.mail” is in use. [Skip] [Stop] [Continue]

The operation can’t be completed because the item “Containers” is in use. [Skip] [Stop] [Continue]]

The operation can’t be completed because the item “Library” is in use. [Skip] [Stop] [Continue]

The operation can’t be completed because the item “testuseraccount” is in use. [Skip] [Stop] [Continue]

...repeat first four errors...

The operation can’t be completed because the item “testuser” is in use. [Skip] [Stop] [Continue]


With no success at emptying Trash, I've tried:

Safe boot and Empty Trash, then Repair Disk with Disk Utility, then Empty Trash.

Recovery Disk boot and Empty Trash, then Repair Disk with Disk Utility, then Empty Trash.

Standard boot then Terminal rm command.

Boot from external USB drive (macOS 10.14.4) and Empty Trash, then Terminal rm command.

Use Cocktail (Mojave Edition) 12.2 to Force Empty the Trash.

Use Windows 10 with Parallels to empty .Trash.


Using Terminal to rm, results are either "Operation not permitted" or "Directory not empty".


So, question 1: Is there anything else to try?

Question 2: If I reinstall Mojave, will a fresh new empty .Trash without these 2 items replace the existing .Trash?


Any help will be much appreciated.


MacBook Pro 15", macOS 10.14

Posted on Mar 6, 2019 10:09 AM

Reply
Question marked as Best reply

Posted on Mar 7, 2019 1:46 AM

The situation is clear for me. 

It seems that you deleted profile data for some user accounts manually (not by user & group management).

Some Mail.app settings in those profiles was locked by system.


You tried fix it by:


Deleting your user account Trash folder:


rm -rf ~/.Trash/*


Resetting the filesystem permissions:


cd ~/.Trash

chflags -R nouchg *


Deleting trash with privileged system access.


sudo rm -rf ~/.Trash/*


Using enabled root account, tried to delete all users accounts Trashes folders.


sudo rm -rf ~/.Trash/*



Keep calm we are close, 3 reboots left. :)


DataVaults are folders to which neither the user nor third-party software has any access at all. The only software which can see and work with their contents are certain Apple-signed products which have a specific entitlement to do so.


At this time, the only other method to acquire access to the directory is to turn off SIP (About System Integrity Protection on your Mac - Apple Support)


Reboot your computer into Recovery Mode by holding down Command + R on startup

Open Terminal from the Utilities menu

Run command:

csrutil disable


Reboot your computer

Login

Open Terminal from the Utilities menu

Run command:

sudo rm -rf ~/.Trash/* 


Reboot your computer into Recovery Mode by holding down Command + R on startup

Open Terminal from the Utilities menu

Run command:

csrutil enable



Similar questions

15 replies
Question marked as Best reply

Mar 7, 2019 1:46 AM in response to sticky moments

The situation is clear for me. 

It seems that you deleted profile data for some user accounts manually (not by user & group management).

Some Mail.app settings in those profiles was locked by system.


You tried fix it by:


Deleting your user account Trash folder:


rm -rf ~/.Trash/*


Resetting the filesystem permissions:


cd ~/.Trash

chflags -R nouchg *


Deleting trash with privileged system access.


sudo rm -rf ~/.Trash/*


Using enabled root account, tried to delete all users accounts Trashes folders.


sudo rm -rf ~/.Trash/*



Keep calm we are close, 3 reboots left. :)


DataVaults are folders to which neither the user nor third-party software has any access at all. The only software which can see and work with their contents are certain Apple-signed products which have a specific entitlement to do so.


At this time, the only other method to acquire access to the directory is to turn off SIP (About System Integrity Protection on your Mac - Apple Support)


Reboot your computer into Recovery Mode by holding down Command + R on startup

Open Terminal from the Utilities menu

Run command:

csrutil disable


Reboot your computer

Login

Open Terminal from the Utilities menu

Run command:

sudo rm -rf ~/.Trash/* 


Reboot your computer into Recovery Mode by holding down Command + R on startup

Open Terminal from the Utilities menu

Run command:

csrutil enable



Mar 6, 2019 2:40 PM in response to sticky moments

before using root account you could also try to


sudo rm -rf /users/*/.Trash



How to enable the root user on your Mac or change your root password - Apple Support


Please login as root, and try to empty folder in normal way if any files in it, if not,

please always be careful with rm. (this command will remove .Trash of any user in system)


 rm -rf /users/*/.Trash


Don't forget to disable root account after.


Mar 6, 2019 11:47 AM in response to ⁤aaplCore

Thanks aaplCore for your response. Neither of these tries resulted in emptying Trash. Here are 2 of the results from Terminal:

Bongo:.Trash cooper$ sudo rm -rf ~/.Trash

rm: /Users/cooper/.Trash/testuseraccount/Library/Containers/com.apple.mail/Data/DataVaults: Operation not permitted

rm: /Users/cooper/.Trash/testuser/Library/Containers/com.apple.mail/Data/DataVaults: Operation not permitted


These show the directories of the folders in Trash are off-limits. Finder shows them each containing a Library folder with a no-entry badge.


Still asking for any help.


Mar 6, 2019 4:10 PM in response to ⁤aaplCore

Thanks again for the suggestion, aaplCore. Root user couldn't empty the Trash and neither could the superuser; I got the same results as in my 1:47PM posting. The item "DataVaults" nested at the end of the path in those directories shows UID of 503. I'm wondering if I can change that UID to my own, 501, that could make a difference.

drwxr-xr-x+ 3 503  staff  96 Mar  5 18:37 testuser

drwxr-xr-x+ 3 503  staff  96 Mar  5 18:37 testuseraccount

Further thoughts?

Mar 6, 2019 8:16 PM in response to sticky moments

Sticky moments, I was having a similar problem with a "folder from ****", as we used to call them, since this past December. I tried all of the usual Terminal tricks -- as mentioned by ⁤aaplCore -- but nothing seemed to work. Whenever I tried to empty the trash, I would get the same message as you stating that the folder was in use.


I recall reading some time ago that this problem sometimes results from a file or folder becoming orphaned from something else that it was once related to. One thing I do know is that this problem has existed on macOS for many years, and there just seems to be no solution for some of us, other than taking very drastic measures.


But then something occurred to me. I do twice daily backups of my entire internal hard drive to an external hard drive.


So, while booted into my internal drive, I opened the desktop icon for my external drive, found the same troublesome folder, and I was able to delete it without a problem.


So, then I thought to myself, "If I boot my machine from my external backup drive, maybe I can do things in reverse."


In other words, maybe I could open the desktop icon for my internal drive, find the troublesome folder, and delete it that way.


So, that is what I did. I booted my iMac from my external drive. But guess what? When I tried to delete that untrashable folder on the internal hard drive, I got the very same error. That is, that it was in use, and couldn't be deleted.


But here's the weird part. Once I booted back into my internal hard drive, the troublesome folder was gone. I think I may have tried to empty the trash once I was booted back into my internal drive. I can't remember now.


But the point is, I finally got rid of that stubborn folder.


I don't know if you have a bootable backup drive, but if you do, you might want to give my technique a shot. It may possibly work for you.


Mar 7, 2019 10:57 AM in response to WordWeaver777

WordWeaver777, thanks for your help. I thought about your technique. My thinking had gone somewhat similarly to yours, but none of my bootable external drives have the troublesome folders that are in the Trash of my internal drive. I became focused on eliminating .Trash anywhere I could since I'm the sole user of the laptop. I'm sure we've all heard this before: "Ya know, I really should make daily backups."

cannot completely empty trash in Mojave

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.