9

This seems to be happening randomly, but every once in a while my "atom ." command in order to open a directory in atom won't work.

I run into the following terminal error - "zsh: command not found: atom".

Once I open up Atom manually, I can go ahead and install shell commands and the command works. However, the shell commands don't seem to be saving.

I've tried to edit my zshrc file and uncommented line two "export PATH=$HOME/bin:/usr/local/bin:$PATH". But this issue seems to still be happening.

Any help would be greatly appreciated!

Thanks!

Marc
  • 299
  • 1
  • 4
  • 10
  • 2
    This would depend very much on where atom is installed (use `which atom` to find out at any time the `atom` command actually works). Then, make sure the containing directory is listed in your `PATH` setting in `.zshrc`. – Jan Krüger Apr 11 '19 at 22:10
  • 1
    When I run the command, which atom, my path is as follows: /usr/local/bin/atom. What do I then need to do? – Marc Apr 11 '19 at 22:12
  • 1
    In that case your export as shown in your question looks okay. You probably have something else somewhere in your config that overrides your `PATH`. (Or, for instance, you're running in an elevated shell using `su` or `sudo`, which may use root's shell config instead.) This is hard to troubleshoot from afar without any further information, though. – Jan Krüger Apr 11 '19 at 22:14
  • 1
    Aah gotcha. Yeah it's a pretty annoying issue. What other information would be necessary to try to troubleshoot it further? – Marc Apr 11 '19 at 22:16
  • Well that's the problem, it's basically a (possibly long) stroll through your home directory, or possibly even other directories like `/etc`. I'd recommend for you to try and understand what is different when the command doesn't work - i.e. what did you do before, what commands did you use in the same shell/terminal window, etc. Once you figure out a pattern, it becomes easier to try and figure out where the problem is coming from. – Jan Krüger Apr 11 '19 at 22:19
  • Sounds good. I'll monitor the issue and try to go from there. Do you have other ideas in the meantime? – Marc Apr 11 '19 at 22:21
  • Not really. It's unlikely to be something really exotic and weird, but I don't really have any more useful ideas right now. - Good luck! – Jan Krüger Apr 11 '19 at 22:22
  • Check your PATH *when the problem is happening*. Seeing what the value *actually is* gives you a place to start in looking for the code that sets it. – Charles Duffy Feb 20 '20 at 23:22

3 Answers3

15

When Atom installs it automatically creates a symlink in your /usr/local/bin. However in case it hasn't, you can create it yourself on your Mac

ln -s /Applications/Atom.app/Contents/Resources/app/atom.sh /usr/local/bin/atom

Now you can use atom folder_name to open a folder and atom file_name to open a file. Hope this helps.

If you get "File exists" and the Atom command still dose not work just delete it and type the command over again.

To delete atom simply cmd+shift+G and paste

/usr/local/bin/atom
metalheadcoder
  • 497
  • 1
  • 4
  • 16
14

I had this issue on my Mac, figured it out with the info below.

To install the atom and apm commands, run "Window: Install Shell Commands" from the Command Palette, which will prompt you for an administrator password.

Steps:

  1. Open Atom

  2. If you press Cmd+Shift+P while focused in an editor pane, the command palette will pop up.

  3. Type/run "Window: Install Shell Commands"

You can also simply open Atom, click "Atom" from the Menu bar, then select "Install Shell Commands"

olmos_there
  • 141
  • 1
  • 3
0

If you're using oh-my-zsh, just uncomment the first line of ~/.zshrc -

# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH

enter image description here

That worked for me !

ARK
  • 3,734
  • 3
  • 26
  • 29