Mojo Installation

Mojo Installation

Following directions from Modular to install Mojo on macOS.1. Revised instructions.


In order to use mojo from the command line and from VSCode there are several steps necessary that are not clearly documented on the modular website. This article describes the specific steps necessary to install Mojo on macOS and configure it for use with VSCode. This article is current as of 5/1/2024


  • Apple Silicon
  • macOS Monterey (12 or later)
  • Python 3.8-3.12
  • Command Line Tools for XCode
  • Uses Homebrew - I already had it installed.
  • Uses curl - I already had it installed via Homebrew


  1. As a normal user - Install modular
$ curl -s | sh -
  1. Setup a modular account

  2. As a normal user - Authorize the modular client

$ modular auth

This will output a URL, where you can confirm the client in your developer account. For example:

To complete auth, open this web page:
  1. As sudo/root - Install the Mojo SDK

If you’ve attempted an install before, first clean things up

$ modular clean

Then install mojo as sudo/root

\# sudo modular install mojo
  1. Update your zshrc or bashrc Be sure to follow the instructions to update your zshrc or .bashrc as described in the output of the previous command.

  2. Test

mojo --version

Install VSCode Mojo Extension

  1. Restart VSCode The VSCode Mojo extension needs the MODULAR_HOME environment variable to work properly. You can either pick this up from your global environment or you can set it specifically in the VSCode Mojo extension settings. Since we just updated our MODULAR_HOME environment variable, let’s keep it simple and use that.

Quit and Restart VSCode

  1. Find the official Mojo extension for VSCode and install

VSCode Mojo Test

  1. Create a file ‘hello.mojo’
  2. Add
  fn main():
  print("Hello, world!")
  1. Run it, and insure you see Hello World in the console output.

Congratulations. You now have mojo support in VSCode