On MacOS Catalina, Atom doesn’t display a window at launch when launched via icon (click on icon) or via launcher (e.g. Alfred or Spotlight) but does produce one when launched via the ‘atom’ command in a terminal

Prerequisites

Description

On MacOS Catalina 10.15.7, Atom 1.53 (installed via homebrew) doesn’t display a window at launch when launched via icon (click on icon) or via launcher (e.g. Alfred or Spotlight) but does produce one when launched via the ‘atom’ command in a terminal

Steps to Reproduce

  1. Click on Atom icon or launch via launcher (Spotlight or Alfred)

Expected behavior:

Main Atom window created

Actual behavior:

No window is created. No window can be opened via keyboard shortcut or by trying to open recent documents.

Reproduces how often:

Reproducible 100%% of the time

Versions

atom –version
Atom : 1.53.0
Electron: 6.1.12
Chrome : 76.0.3809.146
Node : 12.4.0

apm –version
apm 2.5.2
npm 6.14.8
node 12.4.0 x64
atom 1.53.0
python 3.7.9
git 2.29.2

Additional Information

Behaviour is as expected if atom is launched from the command line via the command ‘atom’.

This seems related to issue #21013

1 possible answer(s) on “On MacOS Catalina, Atom doesn’t display a window at launch when launched via icon (click on icon) or via launcher (e.g. Alfred or Spotlight) but does produce one when launched via the ‘atom’ command in a terminal

  1. Tentative fix in progress

    I think I have the fix for this. The cause I’m investigating is related to Gatekeeper.

    Let me know if this bug happens for you right when… You are launching Atom and see Gatekeeper pop up with a loading bar and a message ‘Verifying “Atom”‘, or something about “This was downloaded from the internet, are you sure you want to open this?”. I believe this bug happens when Gatekeeper itself handles launching the app.

    If you see this bug, don’t quit atom, and please see the steps below to help me confirm what the causes is for this issue. Thanks!

    Technical explanation of the buggy startup:

    I see a command-line flag -psn_0_[some six or seven digits here] (something like -psn_0_1234567) applied to the buggy Atom process, when inspecting using htop or ps -ax. I have seen reports elsewhere that this flag is added by Gatekeeper. For example: godotengine/godot#37719

    Our argument parser library yargs thinks this -psn_0_1234567 flag is a bunch of short flags, equivalent to -p, -s, -n, -_, -0, -_, -1, -2, -3, -4, -5, -6, -7. The -_ are converted to boolean true, and then we try to do JS string-only operations on the flags. Doing true.startsWith() results in a TypeError (“path.startsWith is not a function”) very early in our initialization process, leaving the app barely started up at all, and unable to respond to most kinds of input other than quitting.

    Quitting and restarting means Gatekeeper is already familiar with the binary, and it won’t intervene with launching the app. So the flag doesn’t get added, and Atom works fine after a restart.

    Help out with confirming the cause of this issue (if you want)

    If you are on macOS and see this bug, and want to help verify what’s going on, please follow these steps:

    • Don’t quit Atom!
    • Open the “Terminal” app
    • Run this command: ps -ax | grep Atom
      • The long flags on Atom Helper (GPU).app are expected, such as --gpu-preferences=IAAAAAAAAAAgAAAAAAAAAAAA …, so you don’t need to report that. I’m mostly concerned about flags on the main process.
      • You can try this and see if it gives you just the main Atom process: ps -ax | grep Atom | head -n 1

    The result may look something like this:

    65336 ?? 0:02.25 /Applications/Atom.app/Contents/MacOS/Atom -psn_0_5178608

    Please let me know if you see a flag resembling this in the output: -psn_0_5178608 (even if the numbers are different).

    Or if you want, paste the output. That said, I’m going to be posting a fix as a PR for that particular issue, so if you see the exact same thing (and no other exotic flags), then it should be solved soon. (If you see some other flag, particularly one with an underscore _ in it, please do post your results!)