Subl command not working - command not found

2019-03-08 04:04发布

Having loads of difficulty getting this set up. I've fixed up my .bash_profile, 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?

9条回答
唯我独甜
2楼-- · 2019-03-08 04:14

This solved my sublime terminal (subl) command issue after battling for a while on Yosemite here is the source

sudo su
rm /usr/local/bin/subl
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
exit
查看更多
劫难
3楼-- · 2019-03-08 04:17

There might be an issue with having multiple symbolic links to the same target. I removed my link "subl" and my link "sublime" still works.

查看更多
女痞
4楼-- · 2019-03-08 04:20

Launch Sublime Text from the command line on OSX

Following the directions above are what worked for me. I use Sublime Text 3 and only had to c+p the below into the cli. I did this at the root level $ cd ~

If your using Sublime Text 3 c+p this into the command line:

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

If your using Sublime Text 2 c+p this code below into 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

Open a new file from the command line:

$  subl test.rb  // it should open new file test.rb in Sublime Text

Open a project folder

$ subl dir/myProject // opens a new folder inside Sublime

Launch Sublime app:

$ subl // launches Sublime

To open Sublime Help for more detailed options use:

$ subl -h // Sublime help
查看更多
The star\"
5楼-- · 2019-03-08 04:21

I'm gonna document this because it worked on my machine™ and might fix the problem for people who see "file already exists" when they run the command suggested in sarbbottam's answer. I'm not sure I can fully explain it so I may use the wrong terms here or there.

When I dutifully copy-pasted sarbbottam's command, my terminal reported that the file already existed. I had tried copy-pasting several stack overflow answers to this problem into my terminal, so I had symlinks called "subl" and "sublime" in my /usr/local/bin: I could see the file when I listed all files in that directory with "ls -a". So I tried to open the "subl" in a text editor, and it said that the file didn't exist!

So I deleted the "subl" symlink in /usr/local/bin, ran the command, and it worked. I think I accidentally made one for Sublime Text 2 or something, and just figured I'd be overwriting the last one which was not the case.

查看更多
可以哭但决不认输i
6楼-- · 2019-03-08 04:25

create the symlink in /usr/local/bin instead of ~/bin and make sure that /usr/local/binin 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
查看更多
该账号已被封号
7楼-- · 2019-03-08 04:25

Geez louise, this was irritating to figure out. I tried several combinations of using sudo and also including or excluding leading / and escaping spaces in the package name Sublime\ Text.app

For me, what worked for creating the desired symlink was:

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

I did not have to use sudo or modify $PATH. For reference, I am on Mac OS Mojave 10.14. echo $PATH currently (and without any modification by me) shows the following:

$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

You can tell if this worked by typing "which subl" immediately after running the ln command above. If you don't get a line of output showing you where bash found your subl command... then you don't have it. Best of luck!

查看更多
登录 后发表回答