How to add Trash folder to Finder Sidebar in Mojave?

In more recent macOS's (such as Mojave), dragging the ~/.Trash folder to the Finder Sidebar does not work properly anymore. When you do that, the sidebar text displays a ? instead of Trash.

The ? still works temporarily, but after you reboot or run killall Finder, and try to open ? in the sidebar, you get the error "?" can't be opened because the original item can't be found.

Is there a way to add the Trash folder to the Finder Sidebar anymore? This used to work perfectly in Sierra and before.


Note: This is not a duplicate of How can I add Trash icon to the sidebar in Mac OS X Lion? . That solution does not work anymore.

Related links: https://discussions.apple.com/thread/8498936


Solution 1:

Several of us over on MacAdmins pulled this issue apart earlier this year when a user complained that their Sidebar not only wouldn't hold his Trash icon, but kept resetting back to default settings-and-layout on a very regular basis.

The Trash folder complex (and it is complex) has to track files from multiple volumes and from multiple users across those volumes, and several changes they made to the Trash 'engine' to work with APFS affected other parts of the OS.

Sidebar reset has been a minor nagging issue for many years, though, but the cause wasn't figured out until recently: Static user Sidebar items (the things you add to Favourites, etc) are linked to their target by the Finder itself, using an always-running subset of the code that drives 'Folder Actions'. Unfortunately, if a previously-specified target isn't where the Sidebar link code says it thinks it is, it updates its cache with zeros, which causes the Sidebar panel's .plist to reset. The Trash, because of its be-many-things-but-appear-in-one-place nature, cannot maintain a static reference, so the Sidebar goes "ptui!"

Anything that can change its reference - or even disappears and reappears of its own accord, like a network share - should never be put into the Sidebar.

The Sidebar is happy as long as things don't go missing, so how can we make transitory objects like the Trash and network shares appear to always be there? The solution is rather obvious in hindsight:

Aliases.

Make an alias of the item you want in the Sidebar, and add the alias itself to the Sidebar. Aliases are files with their own target references, so they just sit there acting as a middle-man twixt Sidebar and targets.

Make a new folder in your ~/ as a repository for the aliases you want Sidebar favourites for.