I am using VS code 1.8.1 on Mac 10.12.3 (16D32). After launch vscode, I run cmd shift p to open command search field. Then run Install code command in Path. I can see the code got added on PATH but it got removed after I close vs code. Is there a way to add it permanently?
8 Answers
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.
4 Comments
Add this to your ~/.bash_profile
export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
1 Comment
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.
Open bash_profile page
sudo vi /etc/pathsAdd an extra line in the list of PATH folders as
/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/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.
3 Comments
COMMAND + SHIFT + P to open the command window and type in >Shell Command: Install 'code' command in PATH. Then goto terminal and type in which code and add the value from which to /etc/pathssudo unlink /usr/local/bin/code 2. Run "Install code command in Path" again via vs codeVisual Studio Code
rm /usr/local/bin/code ln -s "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" /usr/local/bin/code Visual Studio Code - Insiders
rm /usr/local/bin/code-insiders ln -s "/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code" /usr/local/bin/code-insiders Comments
For Big Sur:
From the official docs:
Note: Since zsh became the default shell in macOS Catalina, run the following commands to add VS Code to your path:
cat << EOF >> ~/.zprofile # Add Visual Studio Code (code) export PATH="\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin" EOF I did this and it worked for me.
Comments
I am running Visual Studio Code - Insiders 1.23.0 on a Mac/Mac OS 10.10.5 Yosemite. I added the "Shell Command: Install 'code-insiders' command in PATH" from within VSC - Insiders. From the terminal in any directory I just add 'code-insiders .' and it launches in VSC - Insiders without issue.
Hope that helps.
Comments
Was facing a similar problem. I had to restart + it never worked from the terminal. Came across this post: https://stackoverflow.com/a/39604469/11306308
The issue for me was that I forgot to move the VS code to Applications folder. It was in the downloads folder for me.
You can just copy paste the vs code 'application' from the downloads folder to the applications folder.
After that, first uninstall it from path (cmd+shift+p -> uninstall code from path) and then install it back.
Restart vs code and now it should work fine.
Also, make sure to update the shortcuts (for me docker) to now use the applications vs code instead of the downloads one.