Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install Visual Studio Code's `code` command permanently?

I just followed the top-voted answer here and successfully installed Visual Studio Code's code command in my terminal.

However, the code command fails to launch Visual Studio Code every time after I restart my MacBook Pro.

~ code
zsh: command not found: code

Is it possible to install code permanently so that I don't have to install it every time I turn on my MacBook Pro?

~ where code
/usr/local/bin/code

~ ls -l /usr/local/bin/code
lrwxr-xr-x  1 myName  admin  167 Aug  5 13:41 /usr/local/bin/code -> /private/var/folders/bh/525lnbns1213cx2651s97my00000gp/T/AppTranslocation/EA379FC4-05D2-4739-BE49-1D8870E47B8A/d/Visual Studio Code.app/Contents/Resources/app/bin/code

I also find out that the folder EA379FC4-05D2-4739-BE49-1D8870E47B8A get deleted after I restart my laptop.

This is the reason that I cannot run code after the laptop is restarted.

Why is code installed in a temporary folder?

My MacBook Pro's version is macOS Sierra version 10.12.6

like image 619
Brian Avatar asked Aug 05 '17 06:08

Brian


People also ask

How do I install VS Code extensions in terminal?

You can manually install a VS Code extension packaged in a . vsix file. Using the Install from VSIX command in the Extensions view command dropdown, or the Extensions: Install from VSIX command in the Command Palette, point to the . vsix file.


2 Answers

The reason that code get installed in a temporary folder is that I placed Visual Studio Code.app in Downloads folder.

After I moved it to Applications folder, launched it, and installed code command, the code is not installed in a temporary folder anymore.

like image 64
Brian Avatar answered Oct 07 '22 00:10

Brian


you can this code in visual studio code command palette to register shell command.
Open the command palette.
shell command
and run this command to install 'code' command
install 'code' command in PATH
And then restart terminal

like image 27
Raymond Sicard Avatar answered Oct 07 '22 01:10

Raymond Sicard