31

I have just upgraded to OS X El Capitan and subl . command stopped working with the zsh: command not found: subl error message.

I have run the following command as suggested in other posts:

sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl

result:

ln: /usr/local/bin/subl: File exists

in the ".bash_profile" as well as ".zsh_profile" I have the following lines saved:

export PATH=/bin:/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:$PATH
export EDITOR='subl -w'

Also tried:

sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/bin/subl

result:

ln: /usr/bin/subl: Operation not permitted

Update: it seemed to work after running the following command:

alias subl="'/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl'"

but as soon as I restart the terminal, subl . command stops working.

Update2: after pasting the following line: alias subl="'/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl'" in the subl ~/.zshrc, subl . command works even after restarting the terminal, but terminal seems to work slower than normal, and when you open relatively small folders with subl . command, at times it's taking ages to show the files...

Final Update: After running sudo rm /usr/local/bin/subl followed by sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl everything works perfectly, thanks to @chris.

Anvar Turobov
  • 449
  • 1
  • 5
  • 13
  • Are you sure the .bash_profile is read by `zsh`? – lenz Oct 02 '15 at 20:41
  • I honestly wouldn't know that, but I have the same lines inside the zsh_profile – Anvar Turobov Oct 02 '15 at 21:03
  • Ok. Type `echo $PATH` on the command line to see if /usr/local/bin is in your path variable. – lenz Oct 03 '15 at 09:48
  • @lenz, typed `echo $PATH` result: `/usr/local/heroku/bin:/Users/anvarturobov/.rbenv/shims:/Users/anvarturobov/.rbenv/shims:/Applications/Postgres.app/Contents/Versions/9.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin` – Anvar Turobov Oct 03 '15 at 13:32

1 Answers1

63

In El Capitan, you are not allowed to write to /usr/bin, but writing to /usr/local/bin is ok. By default, /usr/local/bin should also be in your path variable.

Had the same issue. Deleting and recreating the symlink has fixed the problem. Perhaps the current symlink is pointing to the wrong location after the upgrade.

sudo rm /usr/local/bin/subl
sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl

Or Sublime Text 2 (from – @simen comment):

sudo rm /usr/local/bin/subl
sudo ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl 
Christian Neverdal
  • 5,655
  • 6
  • 38
  • 93
chris
  • 1,312
  • 13
  • 16
  • 2
    Thanks @chris, it worked. I've removed `export PATH=/bin:/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:$PATH` `export EDITOR='subl -w'` from **".bash_profile"** as well as `alias subl="'/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl'" ` from the the `subl ~/.zshrc`. Everything works well so far. Thank you. – Anvar Turobov Oct 03 '15 at 17:11
  • Remember to add "\ 2" if you're using Sublime Text 2: ```sudo ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl``` – simen Oct 28 '15 at 17:49
  • Didn't have to do the `rm` step because it didn't exist, but otherwise perfect solution for me. Thank you. – tscizzle Nov 17 '15 at 15:00