Can I get some help making a symbolic link to run VSCode from the command line?

I downloaded VSCode and tried to make link for code to use code command to open VSCode. I also appended this vscode path to PATH variable. I have downloaded VSCode in folder called Work. This Work folder resides with other folders like Applications, Downloads etc. code is working outside these directories but not inside them. For example if try to run code --version inside Downloads/ it shows command not found.

The commands I used to make link: sudo ln -s Work/Software/VSCode/Visual\ Studio\ Code.app/Contents/Resources/app/bin/.

and my PATH variable is, ....:Work/Software/VSCode/Visual Studio Code.app/Contents/Resources/app/bin/. Please tell me if I doing something wrong. Thanks.


You've both tried to create a symlink and also add the current path to your PATH. These are two separate solutions but you've done both, and neither are correct so neither work. Only do one.

If you want to create a symlink, you need to symlink the code binary to somewhere that already exists in your PATH. That's not what you've done with the command you gave:

sudo ln -s Work/Software/VSCode/Visual\ Studio\ Code.app/Contents/Resources/app/bin/

This will have created a link from a new symlink created in the current directory (where you ran the command) to the given path. This is not what you want and won't solve any problem you're having. Delete the symlink it created and see How can I create a symbolic link in Terminal? — you need to symlink code inside the bin folder to somewhere already in your PATH.

The other solution is to add the existing path to the folder containing code to your PATH.

my PATH variable is, ....:Work/Software/VSCode/Visual Studio Code.app/Contents/Resources/app/bin/

You're missing $HOME/ before Work otherwise the relative path won't be found.