Duplicate app icons in the Dock

dock

Sometimes when opening apps I get duplicate icons in the Dock for that app. This isn't really a problem, however I'm curious why macOS does this (I suppose this is more of a technical question).

This happens a lot especially with VS Code where I often launch the app with the code utility in the Terminal.

Why does macOS think these are different apps when they're the same binary?

Dock screenshot

Best Answer

I don't have a specific answer as to what causes macOS to do this, however there is an issue on the VS Code GitHub repository which has lots of discussions about this (for VS Code app at least).

It seems to have something to do with launching an app directly (executing the binary inside XYZ.app/Contents/MacOS) instead of via Launch Services (the open command).

Related Question