1

I'm using macOS Catalina (10.15.4).

In my /Application folder, I have a file :

localhost:Applications root# ls -al
drwxr-xr-x   3 root      wheel     96 Nov 17 21:42 Karabiner-Elements (之前).app

the characters "之前" is the Chinese word for "previous" or "before" (sorry I cannot find the word in English version). This file is automatically created by OS for duplicate app after I use Migration Assistant to transfer a user account to this Mac.

The file has "Zero Bytes", with only one folder called Contents, which is empty. The /Application/ folder is not locked. I just want to delete the file, but failed, because it's locked. snapshot image: the info of the file

The lock option in general section is gray. The lock icon in the lower-right of the window is also not clickable. The privilege of wheel and everyone cannot be changed, giving the alert: The operation can’t be completed because you don’t have the necessary permission.

I have searched a lot but nothing works. I have tried :

  1. remove to trash, but got :The operation can’t be completed because the item “Karabiner-Elements (之前).app” is locked.
  2. sudo rm got Operation not permitted
  3. sudo chflags -R nouchg got nothing happens, not even error.
  4. sudo chmod 777 got chmod: Unable to change file mode on Karabiner-Elements (之前).app/: Operation not permitted

How can I delete this file?

Giacomo1968
  • 53,069
  • 19
  • 162
  • 212
matrix
  • 111
  • 1
  • 3

3 Answers3

2

The answers are within the image you include. The .app file/folder is "Locked" by the Finder, and you do not have permission to modify (or delete) the file.

Try clicking the lock icon in the lower-right of that Get Info window. Hopefully you can enter your credentials and then unlock the file, then delete it.

If it won't let you unlock/delete it, but it accepts your credentials when you click the lock icon, try explicitly giving yourself R/W permission with the "+" symbol in the lower-left.

jimtut
  • 1,608
  • 2
  • 11
  • 17
  • Can you "sudo chmod 777" it? Alternatively, can you reboot in Recovery Mode and try? Otherwise, you can try this third-party (https://macremover.com/uninstallguides/2019/06/22/remove-karabiner-macos/ ; not tested by myself). –  May 04 '20 at 16:08
  • Thank you jimtut, and sorry for responding late. I tried your suggestion, the lock icon cannot be clicked and the privileges are not modifiable. I have added this in my question. – matrix May 06 '20 at 14:59
  • @Didier Thank you for your advice. `chmod` cannot succeed, I have added this in my question. MacRemover cannot delete it. For me, Recovery Mode is too much for this task, this file doesn't cause any trouble, so if I can't delete it gracefully, I'd leave it this way. – matrix May 06 '20 at 15:11
  • Sorry. That lock icon has always worked for me, assuming that I have permissions to the parent folder. Maybe try the same thing for Applications itself, giving yourself explicit RW permission. Be careful at this level, though, as it might go change ALL the permissions under Apps. That's OK if all you're doing is adding RW for you, but it could have some other unforeseen effects (changing permissions for other users, etc.). But, if you can take control of Apps, then maybe you can click the lock icon here, and make the changes. – jimtut May 06 '20 at 15:14
  • 1
    The only way to make it go away is to uninstall the app it's linked to, aka Karabiner, and the best way I know to do that is with AppRemover, but to each his own, I guess. –  May 06 '20 at 15:56
  • +1 to @Didier. It's just an app. If you can use AppRemover (it might have the same permission problem), you could uninstall the entire Karabiner (including the previous version), and reinstall it (even if that just means making a copy of the main Karabiner app and moving it back later). – jimtut May 06 '20 at 22:32
  • @jimtut, the AppRemover can remove the app, but left the redundant file. Reinstalling the app works fine, but still the file won't go away. In fact, this problem doesn't affect my usage at all, I just want to know how the file can be deleted, just out of curiosity. I believe I can learn some deep mechanic about OS out of it. – matrix May 07 '20 at 02:03
  • After completely uninstalling an app with AppRemover, you can delete whatever leftovers there still are, because their dependencies are gone. You can remove kexts installed by any system-wide application that way, normally. If you really want this file gone, you must uninstall the app that created it first. If it's no trouble to leave it be, then leave it where it is. AppRemover will ask for your admin password to uninstall system-wide applications, every time. –  May 07 '20 at 07:31
  • @Didier This is how it looks in MacRemover: ![img1](https://imgur.com/a/g7zUbeN). Note its name is N/A. After click `run analysis`: ![img2](https://imgur.com/a/zwRkUyF). After click `complete uninstall`: [img2](https://imgur.com/a/AXsrNLU). The file remains there. I believe MacRemover works fine with normal apps, but this is somehow already broken, thus fail. – matrix May 07 '20 at 14:45
  • You've hit a limit with the "free" version of MacRemover that you wouldn't have with AppRemover. My advice: install AppRemover, and let it uninstall Karabiner completely. AppRemover will show a list of items, some already pre-checked, others not. Look at the list, and if your file isn't pre-checked, check it and start the uninstall. Enter your admin password and let it roll. –  May 07 '20 at 16:39
  • @Didier Do you mean OPSWAT AppRemover? Where can I download it, I cannot find official download page for it. – matrix May 08 '20 at 02:19
  • Sorry for misleading you, the app is actually called AppCleaner, not AppRemover... (facepalm emoji) You can find it here: https://freemacsoft.net/appcleaner/ –  May 08 '20 at 06:48
  • @Didier After I enter password and hit , AppCleaner gives alert: `“Karabiner-EventViewer (之前).app” couldn’t be moved to the trash because you don’t have permission to access it. To view or change permissions, select the item in the Finder and choose File > Get Info.` I think I have to face the permission issue directly, If this cannot be done by command line, no uninstall-tool can do it. – matrix May 08 '20 at 15:19
  • You're probably right, and booting in Recovery Mode could help, since most third-party kext are disabled in that mode. –  May 08 '20 at 16:05
2

Use these commands in the Terminal:

sudo chflags nouchg,noschg /Applications/Karabiner-Elements.app
sudo chflags nouchg,noschg /Applications/Karabiner-EventViewer.app

The files are locked to prevent an incomplete uninstall, but you can use the commands above to unlock them manually if you're confident you know what you're doing. I unlocked mine so that I could add tags to the files, which I use to sort my apps.

Full info can be found on the Karabiner web site: https://karabiner-elements.pqrs.org/docs/help/advanced-topics/lock-icon/

  • Welcome to SuperUser! Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the [help center](https://superuser.com/help/how-to-answer). – DarkDiamond Sep 28 '22 at 16:28
-1

just in case anyone else was struggling with uninstalling karabiner, I found another thread which explains you must go through their own interface and press the uninstall button. See here - https://apple.stackexchange.com/questions/362662/how-to-delete-a-locked-app-karabiner