Fix VSCode code . for Mac Terminal
Switching from the PyCharm to VSCode for the light-weighted projects opened some features for the cmd, that I was keen on using. The main one for me was the ability to open any project, just by navigating to the folder, and executing code .
command to open it as a VSCode project.
To make this possible, there are 3 main steps to be done:
- Open VSCode
- Execute
Command + Shift + P
to open the Command Palette - Type in and execute
Shell Command: Install ‘code’ command in PATH
, to add a shortcut to the PATH variable
After doing this all the MacOS users can execute any project from the cmd using the code .
approach, BUT only up to the next restart of the device. Then, to do so, you need to repeat these 3 main steps again and again. To overcome this, I propose adjustments to forget about this problem for the rest of the time.
Be sure, that your Terminal application is not restricted and have access to the disk. To check this navigate to: System Settings -> Privacy & Security -> Full Disk Access
and check whether the slider is set for the Terminal application as in the photo below.
After checking this step, execute your Terminal and run the following command to check restrictions on the VSCode application: xattr “/Applications/Visual Studio Code.app”
, if needed, adjust the path for your System.
That command should return the list of attributes. If that list includes com.apple.quarantine
, then the following command should deal with the problem: sudo xattr -r -d com.apple.quarantine “/Applications/Visual Studio Code.app”
.
After executing the following statements, please, re-do the main 3 steps above and reload your system for the changes to be applied.
Thanks for reading, I hope this solved your problem and you will start using VSCode and cmd on MacOS more often!