Making Visual Studio Code Portable on MacOS: No Extension Installation Required
Visual Studio Code (VS Code) is a popular code editor for developers, known for its lightweight and customizable nature. It is available on various platforms, including MacOS. However, the default installation of VS Code on MacOS requires administrator privileges and installs extensions globally, which may not be desirable for all users.
This article will guide you through the process of creating a portable version of VS Code on MacOS, which does not require administrator privileges and does not install extensions globally. This can be useful for users who want to use VS Code on multiple machines without having to install it separately on each one, or for users who want to use different versions of VS Code for different projects.
Prerequisites
To follow this guide, you will need the following:
- A MacOS machine with the latest version of the operating system installed
- The latest version of VS Code downloaded from the official website
Creating a Portable Version of VS Code
To create a portable version of VS Code on MacOS, follow these steps:
- Open the Terminal app on your MacOS machine.
- Navigate to the directory where you downloaded the VS Code installer. For example, if you downloaded the installer to the Downloads folder, you can navigate to it using the following command:
cd ~/Downloads- Extract the contents of the installer using the following command:
tar -xvf Code-darwin-stable.tar.gz- Move the extracted folder to a location of your choice. For example, you can move it to the Applications folder using the following command:
mv Code-darwin-stable /Applications- Create a new folder in the same location to store your settings and extensions. For example, you can create a folder named "VS Code Portable" using the following command:
mkdir ~/VS\ Code\ Portable- Copy the "User" folder from the VS Code installation to the new folder you created. For example, you can use the following command:
cp -R /Applications/Code-darwin-stable/Contents/Resources/app/User ~/VS\ Code\ Portable- Create an alias to the VS Code installation in the new folder you created. For example, you can use the following command:
echo 'alias code="open -na /Applications/Code-darwin-stable/Code.app --args --user-data-dir=$HOME/VS\ Code\ Portable"' >> ~/.bash\_profile- Restart the Terminal app and run the "code" command to launch VS Code from the new folder. For example:
codeUsing the Portable Version of VS Code
Now that you have created a portable version of VS Code on MacOS, you can use it on multiple machines without having to install it separately on each one. You can also use different versions of VS Code for different projects by creating a new folder for each version and copying the "User" folder to it.
Note that the portable version of VS Code does not install extensions globally. Instead, you can install extensions for each project by opening the Extensions view and clicking the "Install in User Folder" button. The extensions will be installed in the "User" folder in the portable version of VS Code, and will only be available for that project.
- VS Code is a popular code editor for developers, but the default installation on MacOS requires administrator privileges and installs extensions globally
- To create a portable version of VS Code on MacOS, extract the contents of the installer and move the extracted folder to a location of your choice
- Create a new folder to store your settings and extensions, and copy the "User" folder from the VS Code installation to the new folder
- Create an alias to the VS Code installation in the new folder, and restart the Terminal app to use the portable version of VS Code
- The portable version of VS Code does not install extensions globally, but you can install extensions for each project by clicking the "Install in User Folder" button in the Extensions view
References
- Visual Studio Code: https://code.visualstudio.com/
- VS Code for MacOS: https://code.visualstudio.com/docs/setup/mac
- VS Code User Folder: https://code.visualstudio.com/docs/editor/settings#_user-settings
- VS Code Extensions: https://code.visualstudio.com/docs/editor/extension-gallery