System Integrity Protection prevents Trash from being emptied
Solution 1:
- Shutdown your laptop.
- Press Command + R and then the power button to boot into recovery mode.
- Click the Utilities menu and select Terminal.
- Type
csrutil disable
and press return. - Close the Terminal app and restart out of recovery mode.
- Login to your machine normally and launch the Terminal app on your Mac by either searching for it in Spotlight or locating it in the Utilities folder under Applications.
- In Terminal enter this command
sudo rm -rf ~/.Trash/*
it'll ask for your login password. That should clear your trash.
If that worked re-enable SIP.
- Shutdown your laptop.
- Press Command + R and then the power button to boot into recovery mode.
- Click the Utilities menu and select Terminal.
- Type
csrutil enable
and press return. Close the Terminal app and restart out of recovery mode.
Solution 2:
In my case, I had an old backup of my old boot disk and I deleted all files in it. But, some files got stuck and will never go away.
Please note that I have a separate boot disk now and its safe to delete stubborn files from old disk. Please do not try until you know what you are doing.
For me this worked:
Open Terminal
cd /Volumes
ls -la
Check the old boot drive mount point.
cd old_boot_drive
cd .Trashes
sudo ls -la
You will not see your files, but you will see a folder, in my case it was 501.
cd 501
sudo ls -la
Now, you will see the list of all stubborn files in the Trash. Delete them one by one.
sudo rm -rf file1
sudo rm -rf folder2
To delete files OR folders with blank spaces or special characters in them. Please use double quotes.
sudo rm -rf "folder with blanks"
As soon as all files are deleted you will see that Trash icon on your Mac will appear blank now.
Hope it helps someone.