Sub topic 2
Installing VS Code
This chapter covers installing Visual Studio Code (VS Code) and checking that its command-line launcher works. It assumes you can use a terminal and have basic familiarity with VS Code. Later chapters add the Salesforce CLI, Java, and the extensions on top of this editor.
Why VS Code comes first
VS Code is the editor that hosts the Salesforce extensions. The extensions add Apex editing, deployment, testing, and debugging features, but they run inside VS Code and depend on it. Install the editor first so that each later tool has something to attach to.
The chapter also sets up the code command. Later chapters use code . to open a project folder from the terminal, so this step has to work.
Choose a build
Download VS Code from the official site, https://code.visualstudio.com. It is available for Windows, macOS, and Linux. Pick the installer that matches your operating system and CPU architecture.
| Platform | Typical install method | Notes |
|---|---|---|
| Windows | User or System installer (.exe) | Choose "Add to PATH" during setup. |
| macOS | Download the .zip and move the app to Applications | Run the "Shell Command" step described below. |
| Linux | .deb, .rpm, or a package manager | The package normally adds `code` to the PATH. |
Use the Stable build. The Insiders build is a separate, less tested edition that installs side by side. It can work with the Salesforce extensions, but it adds variables you do not need during setup.
Install on your platform
Windows
- Run the installer.
- On the "Select Additional Tasks" page, keep "Add to PATH (requires shell restart)" checked.
- Finish the installer, then close and reopen any terminal windows.
The terminal must be restarted because an open terminal keeps the PATH it started with.
macOS
- Unzip the download and drag Visual Studio Code into the Applications folder.
- Open VS Code.
- Open the Command Palette with
Cmd+Shift+P. - Run Shell Command: Install 'code' command in PATH.
- Open a new terminal window.
Linux
On Debian or Ubuntu, install the downloaded package:
sudo apt install ./code_*.debOn Fedora or RHEL, use sudo dnf install ./code-*.rpm. The package installs the code command for you.
Verify the installation
Open a new terminal and run the check from the tutorial's tool-verification step:
code --versionThe output is three lines. The first is the VS Code version, the second is a commit hash, and the third is the CPU architecture, such as x64 or arm64.
Next, confirm the launcher can open a folder. Run this from any directory:
code .VS Code should open with the current folder in the Explorer. If it does, the editor and the launcher both work.
Common problems
code: command not found. The launcher is not on your PATH. On macOS, run the Shell Command step again. On Windows, reinstall with "Add to PATH" checked, or restart the terminal.- The version works in one terminal but not another. The second terminal was opened before the install and still has the old PATH. Open a new one.
- An unexpected old version appears. More than one copy of VS Code is installed. Run
which code(macOS and Linux) orwhere code(Windows) to see which one is first on the PATH.
Check your understanding
Exercise
You installed VS Code on macOS and can open it from the Applications folder, but running code --version in the terminal gives "command not found". What is the fix?
Show answer
The code launcher is not on the PATH. Open VS Code, open the Command Palette with Cmd+Shift+P, and run "Shell Command: Install 'code' command in PATH". Then open a new terminal window and run code --version again.
Exercise
What are the three lines printed by code --version, and why does the output help when you troubleshoot later?
Show answer
They are the VS Code version, the commit hash, and the CPU architecture. The version lets you check it against the minimum that the Salesforce extensions require. The architecture confirms that you installed the right build for your machine.