VS Code doesn't add command line on path permanently on Mac

So I've just had this issue during setup of a new laptop and found a simple (but slightly embarrassing) solution that worked for me. After faffing about with it for way too long I noticed I had left it in Downloads. I moved the .app file to /Applications and ran the command-line install function again and now the "code" command persists.


Add this to your ~/.bash_profile

export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"

source: https://code.visualstudio.com/docs/setup/mac


I am assuming you've checked this link.

VSCode application generally resides in /Applications/Visual Studio Code.app/Contents/Resources/app/bin/code.

Follow these steps to access VSCode through code on shell.

  1. Open bash_profile page

    sudo vi /etc/paths
    
  2. Add an extra line in the list of PATH folders as

    /Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/
    
  3. Exit from vi: Esc > :wq! > Enter Key

Restart shell. Then do echo $PATH to confirm VSCode has been added successfully.

Check code command is added by typing which code. You should see VSCode path printed on screen.

Try this link if it doesn't work out.

Edit: I am using version 1.9.1 and after I ran Install code command in Path it got added permanently.