macOS Sierra Gatekeeper path randomisation breaks Atom shell commands

Prerequisites

Description

Applications are launched from randomised paths in macOS Sierra

See also Sierra and Gatekeeper Path Randomization

Unfortunately, this means that the /usr/local/bin/{atom,apm} symbolic links that Atom installs are only valid until the next time macOS randomises the application path.

ls -la /usr/local/bin/atom

lrwxr-xr-x 1 ron admin 152 1 Nov 09:51 /usr/local/bin/atom -> /private/var/folders/mx/_pq4c8yx2nl1h05ht_w2m1y40000gn/T/AppTranslocation/C40BC339-2DD1-4FDF-8516-E966D4B4D45D/d/Atom.app/Contents/Resources/app/atom.sh

Possibly related to #12126

Steps to Reproduce

  1. install Atom
  2. launch Atom from Finder / Dock / Spotlight
  3. Atom (menu) -> Install Shell Commands
  4. launch Terminal
  5. atom --help and observe that it works
  6. completely exit Atom and with a few minutes, or reboot macOS
  7. launch Terminal
  8. atom --help and observe the “command not found: atom” error message

Expected behavior: [What you expected to happen]

atom and apm shell commands should continue to work correctly once installed

Actual behavior: [What actually happened]

atom and apm shell commands only work reliably while Atom is open, and only after being reinstalled at least once

Versions

atom --version

Atom : 1.11.2
Electron: 0.37.8
Chrome : 49.0.2623.75
Node : 5.10.0

apm --version

apm 1.12.5
npm 3.10.5
node 4.4.5
python 2.7.12
git 2.10.2

uname -a

Darwin fulmen.local 16.1.0 Darwin Kernel Version 16.1.0: Thu Oct 13 21:26:57 PDT 2016; root:xnu-3789.21.3~60/RELEASE_X86_64 x86_64

1 possible answer(s) on “macOS Sierra Gatekeeper path randomisation breaks Atom shell commands

    1. I uninstalled Atom and cleaned up with rm -rf ~/.atom /usr/local/bin/{apm,atom}.
    2. I re-downloaded from https://atom.io/, decompressed the ZIP by double-clicking it in ~/Downloads.
    3. I dragged Atom to ~/Applications
    4. I launched Atom, choosing “Open” in the Gatekeeper prompt
    5. I installed the shell commands as before

    ls -la /usr/local/bin/{apm,atom}

    lrwxr-xr-x 1 ron admin 81 2 Nov 09:01 /usr/local/bin/apm -> /Users/ron/Applications/Atom.app/Contents/Resources/app/apm/node_modules/.bin/apm
    lrwxr-xr-x 1 ron admin 63 2 Nov 09:01 /usr/local/bin/atom -> /Users/ron/Applications/Atom.app/Contents/Resources/app/atom.sh

    So I’m all fixed here. Thanks!