macOS: Add VSCode to path

Posted on

QUESTION :

Despite the fact that I have taken care of this:

pkaramol@MacBook-Pro bin $ cat /etc/paths
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code

and also ..

 pkaramol@MacBook-Pro bin $ echo $PATH
/usr/local/Caskroom/docker/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code

code executable is still not available:

pkaramol@MacBook-Pro bin $ which code
pkaramol@MacBook-Probin $ code
-bash: code: command not found

ANSWER :

You added the executable code to your PATH statement.

/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code

You want to specify the bin directory. Change the /etc/paths from:

/usr/bin
/bin
/usr/sbin
/sbin
/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code

to by dropping the /code.

/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/Applications/Visual Studio Code.app/Contents/Resources/app/bin

VSCode will do this for you. In VSCode type Cmd+SHIFT+P which will bring up the Command Palette.

Then type shell command and you’ll see an entry for Shell Command: Install ‘code’ command in PATH command

Execute that command it the magic will happen for you.

Leave a Reply

Your email address will not be published.