Skip to content

zsh 'code' command not found


Solution(s)

1. Ensure Visual Studio Code is in Applications folder

Check your “Applications” folder contains the “Visual Studio Code” app.

If it is missing from this folder, find where it is currently located and drag the file into the Applications folder.


2. Add the ‘code’ path to your PATH using terminal

  1. If you are having issues getting the code command to work, an alternative method you can try is to run the following command (adapted from the Alternative Manual Instructions section).

    Terminal window
    echo "export PATH=\"\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin\"" >> ~/.zshrc
  2. Apply Changes

    Save the .zshrc Reload the .zshrc paths with the following command to apply changes immediately:

    Terminal window
    source ~/.zshrc

3. Add the ‘code’ path to your PATH manually

  1. Locate Your .zshrc File

    The .zshrc file is located in your home directory at ~/Users/(your username)/.

    If you don’t see it, press Shift + Command + . (dot) to toggle hidden files visibility in Finder.

  2. Identify Your Username (Optional)

    To ensure you’re in the correct directory, you can use the whoami command in Terminal to check your username:

    Terminal window
    whoami

    Username Check Example

  3. Add VS Code to PATH

    Open the .zshrc file with a text editor and add the following line at the end to include the Visual Studio Code path:

    Terminal window
    export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
  4. Apply Changes

    Save the .zshrc file and then reload it with the following command to apply changes immediately:

    Terminal window
    source ~/.zshrc

4. Update permissions

If you are still having issues, try following the steps on the 3. .zshrc permission issues page first, then come back to repeat the steps above.