Skip to main content
The Visual Studio Code CLI is available for Windows, macOS, and Linux. This guide will help you install and configure the CLI on your system.

Installation Methods

The CLI is included with VS Code installations. After installing VS Code, the code command should be available in your terminal.

Verifying Installation

code --version
If the command is not found, you may need to add it to your PATH:
The installer should add VS Code to your PATH automatically. If not:
  1. Open VS Code
  2. Press Ctrl+Shift+P to open the Command Palette
  3. Type “shell command” and select Shell Command: Install ‘code’ command in PATH

Building from Source

For developers who want to build the CLI from source:
Building from source requires Rust toolchain and additional dependencies.

Prerequisites

1

Install Rust

Install Rust using rustup:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
2

Clone the repository

git clone https://github.com/microsoft/vscode.git
cd vscode
git submodule update --init --recursive
3

Navigate to CLI directory

cd cli
4

Install platform-specific dependencies

Install OpenSSL:
# Install vcpkg
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
.\bootstrap-vcpkg.bat

# Install OpenSSL
.\vcpkg install openssl:x64-windows-static-md
5

Build the CLI

cargo build --release
The compiled binary will be in target/release/code.
On Windows, OpenSSL is required for key exchange in tunnel forwarding. The CLI uses OpenSSL for cryptographic operations until all Chromium-based clients support ED25519 key exchange natively.Steps to install:
  1. Follow vcpkg setup instructions
  2. Add vcpkg directory to your PATH
  3. Run vcpkg install openssl:x64-windows-static-md
  4. Restart your terminal
  5. Run cargo build

Post-Installation Setup

Setting Default Data Directory

The CLI stores its data in a default directory. You can customize this:
# Set via environment variable
export VSCODE_CLI_DATA_DIR="$HOME/.vscode-cli"

# Or use the flag with each command
code --cli-data-dir "$HOME/.vscode-cli" tunnel

Configuring Logging

Set up logging for debugging:
# Enable verbose logging
code --verbose tunnel

# Set specific log level
code --log debug tunnel

# Log to a file
code --log-to-file /path/to/logfile.log tunnel

Verifying Installation

Run these commands to verify your installation:
code --version
Expected output:
Visual Studio Code CLI - 1.x.x (commit xxxxxxxx)

Usage: code [options][paths...]

To read output from another program, append '-' (e.g. 'echo Hello World | code -')
...

Updating the CLI

Integrated CLI

When installed with VS Code, the CLI updates automatically when you update VS Code.

Standalone CLI

For standalone installations, use the update command:
# Check for updates
code update --check

# Update to the latest version
code update
The update command is only available in standalone CLI installations.

Troubleshooting

Solution:
  1. Verify VS Code is installed: Check if VS Code exists in your Applications/Program Files
  2. Add to PATH manually (see installation methods above)
  3. Restart your terminal after adding to PATH
  4. On macOS/Linux, make sure your shell profile is sourced: source ~/.bashrc or source ~/.zshrc
Solution:
  1. Ensure vcpkg is properly installed
  2. Verify OpenSSL package: vcpkg list | grep openssl
  3. Install the correct variant: vcpkg install openssl:x64-windows-static-md
  4. Restart your terminal and try building again
Solution:
  1. Make the binary executable: chmod +x /path/to/code
  2. Check directory permissions
  3. Don’t run with sudo unless necessary
Solution:
  1. Ensure you’re using the correct binary (check with which code)
  2. Update VS Code to the latest version
  3. Reinstall the shell command from VS Code’s Command Palette

Uninstallation

The CLI is removed when you uninstall VS Code. You may also need to:
  1. Remove the PATH entry from your shell profile
  2. Delete CLI data directory: ~/.vscode-oss/cli or ~/.vscode/cli

Next Steps

Commands Reference

Explore all available CLI commands

Remote Tunnels

Set up remote access with tunnels

Configuration

Configure the CLI for your needs

CLI Overview

Learn more about CLI features