Mojo Install and Setup
Before you write a single line of Mojo, you need the right tools on your computer. This topic walks you through installing Mojo, setting up your editor, and confirming that everything works correctly. The process takes about ten minutes.
What You Need Before Installing
Mojo runs on Linux and macOS. Windows users can run Mojo inside Windows Subsystem for Linux (WSL). Check that your system meets these requirements:
Operating System
Ubuntu 20.04 or newer is the most tested Linux environment. macOS 12 (Monterey) or newer works on both Intel and Apple Silicon Macs. Other Linux distributions work if they support glibc 2.28 or higher.
Internet Connection
The installer downloads packages during setup. A stable connection speeds up the process.
Installing the Magic Package Manager
Modular distributes Mojo through a tool called Magic. Magic handles Mojo installations, updates, and project environments the same way npm handles JavaScript packages or pip handles Python packages.
Your Computer
|
▼
[ Magic ] ←── manages ──→ [ Mojo SDK ]
| |
▼ ▼
[ Projects ] [ Compiler + Tools ]
Open your terminal and run this single command to install Magic:
curl -ssL https://magic.modular.com | bash
The installer downloads Magic and places it in your home directory under ~/.modular/bin. After the command finishes, restart your terminal or run the command it prints to update your PATH.
Confirm Magic Is Working
magic --version
You see a version number like magic 0.3.0 or similar. Any version number means the installation succeeded.
Installing Mojo
With Magic in place, create your first Mojo project. Magic sets up an isolated environment so Mojo files for one project do not clash with another.
magic init my-first-mojo --format mojoproject cd my-first-mojo
This command creates a folder called my-first-mojo with a configuration file inside. Magic downloads the Mojo compiler and standard library into this environment automatically.
What the Folder Looks Like
my-first-mojo/
├── mojoproject.toml ← project config
└── src/
└── hello.mojo ← starter file (sometimes auto-created)
The mojoproject.toml file records which version of Mojo your project uses. This ensures your code works the same way months later, even if Mojo releases updates.
Choosing a Code Editor
You can write Mojo in any plain text editor, but a proper code editor gives you syntax highlighting, auto-complete, and error hints as you type.
VS Code (Recommended)
Visual Studio Code is free, works on all platforms, and has an official Mojo extension from Modular. Install VS Code from code.visualstudio.com, then open the Extensions panel (the square icon on the left sidebar), search for Mojo, and install the extension published by Modular.
VS Code
└── Extensions Panel
└── Search: "Mojo"
└── Install: Mojo (Modular) ✓
Other Editors
Neovim users can add Mojo support through the nvim-lspconfig plugin using the mojo language server. JetBrains IDEs do not yet have an official plugin but community plugins exist. Any editor that supports LSP (Language Server Protocol) can work with the Mojo language server that ships with the SDK.
Running Your First Mojo File
Create a file named hello.mojo inside your project folder and add this content:
fn main():
print("Hello from Mojo!")
Save the file and run it from your terminal:
magic run mojo hello.mojo
The terminal prints:
Hello from Mojo!
That output confirms the compiler works, the environment is correct, and your editor saved the file properly.
The Mojo REPL
Mojo includes an interactive shell called the REPL (Read-Eval-Print Loop). It lets you type code and see results immediately without saving a file first — useful for quick experiments.
Start the REPL with:
magic run mojo
You see a prompt:
Welcome to Mojo! 🔥 1>
Type any expression and press Enter:
1> 2 + 2
4
1> print("REPL works!")
REPL works!
Press Ctrl + D to exit the REPL.
Updating Mojo
Mojo releases updates frequently. Update your project's Mojo version with:
magic update
Magic downloads the latest compatible version and updates mojoproject.toml. Your existing code continues to work unless a breaking change was announced in the release notes.
Troubleshooting Common Issues
Command Not Found After Install
Your terminal does not know where Magic lives yet. Run the source command that the installer printed, or open a new terminal window. On bash, the installer appends a line to ~/.bashrc. On zsh, it appends to ~/.zshrc.
Slow Download
The Mojo SDK is several hundred megabytes. On a slow connection, the first magic init can take several minutes. Leave the terminal open and wait — Magic shows a progress bar.
macOS Security Warning
macOS may warn that the Magic binary is from an unidentified developer. Go to System Settings → Privacy & Security → scroll down and click Allow Anyway next to the Magic entry.
Key Takeaways
You install Mojo through the Magic package manager using a single curl command. Magic manages your Mojo version per project, keeping different projects isolated. VS Code with the Mojo extension gives the best editing experience. The mojo command runs files directly and also provides an interactive REPL for quick experiments.
