App Translocation and Dock's peculiar bug
Setting up my new MacBook Pro, I had a quite peculiar bug that manifested itself in these symptoms:
- Apps in
/Applications
ask to be moved to/Applications
when opened - Apps dragged into Dock might become question marks after restarting
- Apps dragged into Dock then clicked on will open the app as a duplicate or a “new icon” (see Tower in this case)
Running defaults read com.apple.Dock | grep Tower.app
and inspecting the result in the different stages of this bug showed a pattern: Apps with no problem showed their entries as CFURLs to their locations, and so did the affected apps. Except, after restarting, the affected apps’ CFURLs turned into some really long path under /private, expecting the app to be under a subdirectory of “AppTranslocation”. You can see where this is going.
It turns out, this issue is related to a new feature in macOS Sierra called App Translocation. As explained in that article, apps with the extended attribute com.apple.quarantine
will be moved and started from another location when opened, for security reasons. Which lead me to think that some apps have not had their quarantine correctly cleared after being downlaoded and launched the first time.
You can remove the extended attribute with the command xattr -d com.apple.quarantine <app>.app
. This worked, and the affected app behaved like expected even after restarts. Obviously it’s not good to have this extended attribute.
In fact, let’s remove all quarantine attributes from all apps. Just cd /Applications
and run
ruby -e '`xattr * | grep quarantine`.each_line { |l| `xattr -d com.apple.quarantine "#{l.split(":").first}"` }'
(can probably be done with sed
and exec
but I can’t be bothered)
Glad to have this sorted out. 💦