I want to add the sublime lib to my path but it has a space in it.

I have tried the obvious like you would navigate in the terminal ( e.g. /Applications/Sublime\ Text\ 2.app/Contents)

export PATH="/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl:$PATH"

But I still get the error

/Applications/Sublime: No such file or directory

I could rename it but I am curious how to resolve it. I am using bash.

  • try export PATH='/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl:$PATH? Also, is that newline intended?
    – demure
    Jun 22, 2013 at 18:54
  • No its not a new line just comes out that way when I pasted it in. Your suggestion didn't help and it killed my path so couldn't use vi, had to switch to a different shell to change back. Jun 22, 2013 at 19:02
  • 1
    demure's suggestion should do it, but use double quotes: export PATH="/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl:$PATH", otherwise $PATH won't be expanded.
    – jaume
    Jun 22, 2013 at 19:04
  • I had it as double quotes originally but in the .bashrc it still didn't like it. Jun 22, 2013 at 19:25
  • Could you be more precise? What do you mean by "it didn't like it"? Do you get an error (which one)? Or it simply didn't work?
    – jaume
    Jun 22, 2013 at 21:04

4 Answers 4


Use backslash or quotes, not both. You put the sequence backslash-space in the PATH value.

export PATH="/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl:$PATH"


export PATH=/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl:$PATH

Be sure not to wrap the line: it has to be spaces, not newlines.

Note that if you see an error like /Applications/Sublime: No such file or directory from the export PATH=… line, then you have a syntax error in that line, such as a space after the equal sign: the assignment doesn't try to look up the directory. If the error is at some later time, then it isn't due to the PATH value, or if so only very indirectly: it's perfectly ok for entries in $PATH not to exist, and a non-existent directory will not lead to an error message.


If the path is set properly at .bash_profile, whether with double quotes or backslash-escaped and has spaces in it, you need to call the variables with double quotes.

For example, if .bash_profile is set like below:

export SUBLIMEPATH="/Applications/Sublime Text 2.app/Contents"
export PATH=$PATH:$SUBLIMEPATH/SharedSupport/bin/subl

You can't do cd $SUBLIMEPATH to change the current directory, you'll get No such file or directory error. But with double quotes such as cd "$SUBLIMEPATH" you can.

Hope this help for something.


To resolve it I made a simlink in

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

I then added it to my path by using vi on ~./bashrc

export PATH="/usr/local/sublime/bin/:$PATH"

Remember to source the .bashrc to pick up your changes

source ~/.bashrc

This doesn't answer the question. However, it addresses as remark made in one of the answers, and discusses a similar procedure.

It is also possible to create an alias for Sublime Text by editing .bash_profile or .bashrc (whichever is the BASH configuration file in your home directory).

alias sublime="/Applications/Sublime\ Text.app/Contents/MacOS/Sublime\ Text"

In order to do so, it is necessary to use BOTH escape back slashes and quotes. Note in particular that this is a very different situation from exporting the PATH as mentioned above, because there it only makes sense to do one or the other, but not both.

Note also that it isn't necessary to create a symlink first, as the official Sublime documentation and many other sources claim. This answer on StackOverflow gets it right.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .