Subl command not working - command not found

I'm having difficulty getting this set up. I fixed my .bash_profile, and created the symlink using the following command from the Sublime website:

ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl 

Yet, when I input that command I get:

ln: /Users/my_username/bin/subl: No such file or directory

It appears my terminal is looking at the wrong place for the file? Why is it trying to point to a bin folder on my home directory?


Solution 1:

Create the symlink in /usr/local/bin instead of ~/bin and make sure that /usr/local/bin in in PATH.

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

If you don't find /usr/local/bin/, then add the following lines to your .bashrc or .zshrc:

PATH=$PATH:/usr/local/bin/; export PATH

Solution 2:

This solved my Sublime terminal (subl) command issue after battling for a while on Yosemite:

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

Here is the source.

Solution 3:

"Launch Sublime Text from the command line on OSX" worked for me. I use Sublime Text 3 and only had to copy and paste the commands below to the command-line. I did this at the root level

$ cd ~
  • If you're using Sublime Text 3 copy then paste this to the command line:

    // Sublime Text 3
    $ ln -sv "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
    
  • If you're using Sublime Text 2 copy then paste this to the command line:

    // Sublime Text 2
    $ ln -sv "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
    

Now test it out to see if it works:

  1. Open a new file from the command line:

    $  subl test.rb  // it should open new file test.rb in Sublime Text
    
  2. Open a project folder:

    $ subl dir/myProject // opens a new folder inside Sublime
    
  3. Launch Sublime app:

    $ subl // launches Sublime
    

To open Sublime Help for more detailed options use:

$ subl -h // Sublime help