5

Since the App Store seemed stuck with updating Xcode to 7.3, I have decided to delete it and reinstall. However, after moving Xcode to the Trash, it refused to be cleared and instead be stuck on the "Preparing to empty the trash..." window. So, I've decided to force empty the trash in Terminal by rm -rf ~/.Trash/*, only to get an endless loop of error message saying this:

rm: /Users/jordanchanph/.Trash/Xcode.app/Contents/.../IOCatalogue/reset.xml: Permission denied

How can I empty the trash?

6
sudo rm -rf ~/.Trash/*

is your friend.

I would think cause of the errors are permissions, perhaps Xcode sets files with permissions exclusive to root (superuser).

What sudo does is run the following command (rm -rf ~/.Trash/*) with root privileges - think of it as "when in doubt with permission denied, sudo". Of course, the permission denied error is not to be ignored as it could be a sign of permissions errors. But, if you know what you are doing, sudo solves your problems. (this sums it up nicely)

| improve this answer | |
  • 1
    And what if it does not work and hangs instead ? – Renetik Jul 23 '18 at 5:15
  • It does not work (The operation can’t be completed because the item “zh_TW.lproj” is in use.) and in console (/Users/Maxim/.Trash/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/Social.framework/XPCServices/com.apple.vimeo.xpc/zh_TW.lproj: Directory not empty), but it is empty "Shit Shitapple Apple Shit"... – Maxim Sep 16 at 2:17
1

Make sure of the following:

  • No Apple devices (iOS, iPad, ...) are connected to your computer (MacOS Catalina or later)
  • iTunes is not open or running (MacOS High Sierra or earlier)

They hog some resources XCode uses and therefore prevent it from being deleted.

| improve this answer | |
  • 1
    This was a key point for me. I had tried all of the reboots and "sudo removes" and had all devices unplugged from my machine... but I still couldn't delete xcode. After seeing this, I realized that my phone was connecting via wifi, so I turned off wifi and bluetooth, and the regular "empty trash can" method worked. – William Terrill Dec 30 '19 at 19:59
0

I ran (rm -rf ~/.Trash/*) on my MacBook Pro (mid 2012) running 10.13.6 and it hung.
I opened up Trash, right-clicked on XCode and opened up Package Contents, then clicked "delete immediately" while the 'rm' command was still running. I saw "deleting 0 items". I terminated the 'rm' command and 'x'd out of the "deleting 0 items" window.

Now comes the strange part. I clicked on the name of one of the components, intending to edit it (that has worked for me in the past). Instead of taking my edit, it the editing highlight disappeared, and then the component itself went away.
I did this successively for the other components, and after the last one, XCode itself vanished from the Trash folder.

I don't have an explanation, but I suppose the point is that this technique worked.

| improve this answer | |

You must log in to answer this question.

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