Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems using subl command in terminal: "Command not found" & "No such file or directory"

I want to apologize in advance that this is a newbie question! I've spent the last 2 hours trying to find a solution.

I have two problems (I'm sure related).

Background:

This is what my $PATH looks like:

/Users/Sponsi/.rvm/gems/ruby-1.9.3-p194/bin:/Users/Sponsi/.rvm/gems/ruby-1.9.3-p194@global/bin:/Users/Sponsi/.rvm/rubies/ruby-1.9.3-p194/bin:/Users/Sponsi/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin

Problem #1

I am trying to use the command-line command "subl" to launch Sublime Text 2 on OSX.

I entered the following command: "ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl

It only halfway worked - when I enter "subl" I get "Command not found". But when I re-enter the command above it says "Already exists."

I searched online and found a (somewhat) fix. I added the following to my .bashrc:

echo 'export PATH="./bin:$PATH"' >> ~/.bashrc 
source ~/.bashrc

Using the command "subl" does work but only temporarily. If I exit terminal or switch to another directory it stops working (bringing me into problem #2, see below.)

Problem # 2:

When I try to pull up a file under another directory using the command "subl" I get "-bash: ./bin/subl: No such file or directory" I confirmed the file I want to edit does exist.

BTW, I am following the Ruby tutorial found @ http://ruby.railstutorial.org/ruby-on-rails-tutorial-book

Thank you so much for your time!

like image 259
Ralitza Avatar asked Jun 05 '12 06:06

Ralitza


People also ask

What does SUBL do in terminal?

Documentation Command Line Interface. Version: Sublime Text includes a command line tool, subl , to work with files on the command line. This can be used to open files and projects in Sublime Text, as well working as an EDITOR for unix tools, such as git and subversion.

How do I run sublime from terminal?

Just Use the command subl to open sublime text from terminal. if you want to open a specific file use subl path/to/the/file . But sublime text must be installed using ppa.


2 Answers

Run each command in the Terminal (in this order):

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

This should work!

Note: First you should check that your sublime's app is in Applications folder and it's name is Sublime Text 2, if not, you should change the name in the second command and type the name of sublime's app.

like image 61
isanjosgon Avatar answered Sep 21 '22 08:09

isanjosgon


if you are using RVM, do this:

ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/.rvm/bin/subl
like image 29
Bob Walsh Avatar answered Sep 18 '22 08:09

Bob Walsh