2

I'm on OS X, but since this is terminal work I figured this was the best place to ask. I'm trying to get Sublime Text to work at the command line via subl and having no luck. I ran ln -s <location of subl file in Applications; not part of $PATH> /usr/local/bin/subl to create a link to it.

When I run ls on /usr/local/bin, I can see the subl link there in the directory.

But when I try to run it, it tells me Command not found. And if I try it with an absolute path by typing in /usr/local/bin/subl, it tells me No such file or directory. I'm not sure how to troubleshoot this. Ideas?

The output of readlink /usr/local/bin/subl is

/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl
  • 1
    It's a binary for the wrong platform, or perhaps (not sure what error message you get on OSX in this case) a script with an invalid shebang. Same problem as unix.stackexchange.com/q/11000, unix.stackexchange.com/q/13391, unix.stackexchange.com/q/101429, etc. I'm not closing as a duplicate (yet) because the investigation steps may be a little different on OSX. What's the output of file /usr/local/bin/subl? – Gilles Jul 5 '15 at 22:37
  • "broken symbolic link to <path>"....researching that but causes for other people so far not applicable here. – temporary_user_name Jul 5 '15 at 22:39
  • Whats the output of ldd /usr/local/bin/subl and echo $PATH? – eyoung100 Jul 5 '15 at 22:45
  • 1
    Ah, this one is different, but it should be obvious: you made a mistake when creating the symbolic link. <Guess> Is this a relative symlink? Note that the symlink is relative to the directory where it's in, not the current directory at the time you invoked ln -s. – Gilles Jul 5 '15 at 22:48
  • Already checked that @Gilles, was not the case. I used an absolute path. eyoung100, don't think ldd exists for macs but I tried using otool -L subl at the internet's suggestion as a drop-in replacement and it just said No such file or directory. – temporary_user_name Jul 5 '15 at 22:48
1

You have an extra backslash in your symbolic link. The actual path is

/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl

but you created a symbolic link to

/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl

When you use the text of the symbolic link in the shell, the backslash is interpreted as an escape character, so you get the right path. But you somehow quoted the backslash when you created the symbolic link, so you ended up with a backslash where there shouldn't be one.

Fix the symlink: run

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

Tip: use completion when refering to an existing file. This way you won't mistype the name.

  • I did use completion...that's how I got it like that in the first place! Your suggestion here is the same thing I originally put in. I tried it again, copied and pasted what you wrote here, and ended with the same problem. Good guess though! – temporary_user_name Jul 6 '15 at 23:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.