Permission denied when trying to make sublime text shortcut - macos

So I just started getting into using terminal to manage files etc, and I was trying to setup my sublime text shortcut using this line of code:
ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime
However, when I try to do this it says Permission Denied and I have no idea why. I am using a Mac running Mac 10.10.2.

For sublime text 3:
sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime

If you look at the permissions on /usr/local/bin you will see it is owned by root:
$ cd /usr/local
$ ls -l .
total 0
drwxr-xr-x# 8 root wheel 272 Apr 16 11:31 bin
drwxr-xr-x 3 root wheel 102 Apr 16 10:02 include
drwxr-xr-x# 3 root wheel 102 Apr 16 10:19 share
Therefore you need to use sudo to gain super user privileges. You will need to enter your user account password and you will need to be an Admin user (see System Preferences > Users & Groups):
$ sudo ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin
Note that you don't need the trailing subl on the destination as ln will figure that out itself.

If you are on Mac, I would suggest creating a file /usr/local/bin/sublime or somewhere else on your PATH and putting open -a Sublime\ Text $# inside instead of creating a link. open -a tells Mac to open an application that is in your /Applications/ directory. and the $# symbol passes on any additional arguments that you supply to the script. Thus, you can open a file by doing sublime file.ext. That said, it is possible that your permission denial is that you don't have permission for the /usr/local/bin directory. If that is the case, you need to change the permission using chmod, or just put the script somewhere else like ~/bin

In addition, if you're using Sublime Text 3, this is the correct command for the symlink:
ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl

Related

How to fix opening sublime from terminal in MacOS?

I want to be able to open the sublime text editor in MacOS (14.10.6) from the command line. I found several instructions how to do that (HERE and HERE), but of course it does not work for me.
I did create the symbolic link to the application in /usr/local/bin:
sublime -> /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl
The file at location /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl does exist. Also, the folder /usr/local/bin is included in the actual definition of PATH.
However, the command is not found when I enter it on the command line in a terminal
~$ sublime
-bash: sublime: command not found
Proof:
$ls -al /usr/local/bin | grep sublime
lrwxr-xr-x 1 root admin 63 Jan 15 07:44 sublime -> /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl
$ echo $PATH
/usr/local/opt/python#3.8/bin:/usr/local/opt/python#3.8/bin:/Users/adietz/miniconda3/bin:/usr/local/bin:/Users/adietz/.pyenv/shims:/Users/adietz/opt/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/puppetlabs/bin:/opt/X11/bin
Any ideas how to fix that?
You may use the open command, as the manual says:
DESCRIPTION
The open command opens a file (or a directory or URL), just as if you had
double-clicked the file's icon. If no application name is specified, the
default application as determined via LaunchServices is used to open the
specified files.
Option -a is suitable for MacOS applications, then
open -a sublime\ text
(or alike) should work.
You can then alias it and call it when needed:
alias sublime="open -a sublime\ text"
sublime

Can't create link to atom editor on OSX for atom or sublime editors

First of all I do not have a directory /usr/local/bin, everything is loaded in /usr/bin.
The command
sudo ln -s /Applications/Atom.app/Contents/Resources/app/atom.sh /usr/bin/atom
or the similar one for subl fails with the error:
sudo ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin
Operation not permitted.
Any hints will be much appreciated.
I created the directory /usr/local/bin, I changed the owner to root and I changed the accessing rights to 755.

Why isn't Sublime Text link created?

I'm trying to get Sublime Text 2 to open from Terminal. I'm using the following:
MacBook-Pro:project2 myusername$ ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl
ln: /Users/myusername/bin/subl: No such file or directory
I'm not sure what is wrong. I'm following all the examples out there. Am I missing something?
Here's the output of an echo $PATH (updated path):
/Users/myusername/bin:/Users/myusername/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin
This is on OSX 10.11.1
You most probably do not have a bin folder in your home directory. Create one by using
mkdir ~/bin
This will create the bin folder in your /Users/yourusername/ directory. In terminal the ~ is short for your home.
You will also have to append this folder to your path, i.e. create (or edit if it exists) a .profile file in your home directory and give it this content:
export PATH=/Users/yourusername/bin:$PATH
You will have to open a new terminal for this change to take place.
Use one of these 2 commands:
sudo ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl ~/bin/subl
or
sudo ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl

Symlink to application in mac

I created a symlink to sublime text editor like this in my bin folder:
ln -s /Applications/Sublime\ Text\ 2.app/Contents/MacOS/Sublime\ Text\ 2 ~/bin/sublime
I exported the bin folder to the PATH in .bash_profile like this:
export PATH="$HOME/bin:$PATH"
When I try to open sublime by typing sublime in terminal i get:
xxxxx#xxxx-Air:~$ sublime
2015-08-06 08:05:16.238 sublime[2495:355442] Sparkle Error: the bundle being updated at {
} has no CFBundleIdentifier! This will cause preference read/write to not work properly.
On the other hand, when I try to type the full path like this it works fine:
xxxxx#xxxxx-Air:~$ /Applications/Sublime\ Text\ 2.app/Contents/MacOS/Sublime\ Text\ 2
Is there something wrong with my symlink?
To launch Sublime Text 2 from the Mac OS X Terminal, create a symlink to SharedSupport/bin/subl instead of MacOS/Sublime\ Text\ 2:
ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl ~/bin/subl
Yeah. When you did the ln -s command, you didn't link all the way to the binary file for the app. So you got a wacky / unexpected response instead of launching that editor.
Try doing this instead:
ln -s /Applications/Sublime\ Text\ 2.app/Contents/MacOS/Sublime\ Text\ 2 ~/bin/sublime

Too many levels of symbolic links osx Lion

i'm try to install a libraries but when the make file try to attempt to Developer folder it appear message
Too many levels of symbolic links.
So i try:
Go home folder (cd /)
then i try:
bash-3.2# cd Developer
and this is the output:
bash: cd: Developer: Too many levels of symbolic links
what could be the problem? can you help me?
ls -l
says me
lrwxr-xr-x 1 root wheel 10 14 Mar 09:13 Developer -> /Developer
Use absolute paths when making symlinks:
Doesn't (always) work:
ln -s file ../new/path
Works (more often):
ln -s /full/path/to/old/place/ /full/path/to/new/place/
If go to:
cd /
and ls -la outputs:
lrwxr-xr-x 1 root wheel 10 14 Mar 09:13 Developer -> /Developer
That's a problem. /Developer should be a folder, not a symlink pointing to itself.
Find out where the original /Developer directory is and delete the symlink, so you can create one pointing to it. If you can't find it, consider reinstalling XCode.

Resources