0Pricing
Mojo Academy · Lesson

Running with mojo run

Execute a program from the command line.

Running with mojo run is a free Mojo Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Mojo Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

From File to Running Program

You have a saved hello.mojo file. To see it work, you launch it from your terminal with the mojo command. 🖥️

The mojo run Command

The simplest way to execute a file is mojo run followed by the file name. Mojo compiles and runs it in one step.

mojo run hello.mojo

Run from the Right Folder

Open your terminal in the folder that holds the file, or give the full path. Otherwise Mojo cannot find hello.mojo to run.

cd my_project
mojo run hello.mojo

See Your Output

After you press enter, Mojo prints the program's output right in the terminal. Your greeting appears on the next line.

Hello, world!

The Shorter Form

You can often drop the word run and just pass the file: mojo hello.mojo does the same thing as mojo run.

mojo hello.mojo

Edit, Save, Run Again

Change the code, save, and run the command again to see new output. This quick loop is how you learn fast in Mojo.

Reading an Error Message

If you have a typo, Mojo stops and prints an error with the line number. Read it, fix that line, and run once more.

Run Just Checks for main

mojo run expects your file to have a main function. Without one, it has nothing to start, and you get a clear error.

Building an Executable

For a faster standalone program, mojo build creates an executable file you can run directly, without compiling each time.

mojo build hello.mojo

run vs build

Use run while learning and iterating, since it is one quick step. Reach for build when you want a finished binary to ship or reuse.

Your Workflow Is Set

Write code, save the file, type mojo run, read the output. That short cycle is the core habit of every Mojo session.

Quick Check

You want to compile and execute hello.mojo in a single terminal step. Which command does that?

Recap

Use mojo run from the file's folder to compile and execute in one step, read the output, then edit and run again. 🎯

Frequently asked questions

Is the “Running with mojo run” lesson free?

Yes — the full text of “Running with mojo run” is free to read here on the web, and the Mojo Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Mojo Academy course, upgrade to CoddyKit PRO.

What will I learn in “Running with mojo run”?

Execute a program from the command line. You practise Mojo Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Mojo Academy?

No prior experience is required. Mojo Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Running with mojo run” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Mojo Academy lesson?

Yes. Every Mojo Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Your First .mojo File
  2. The main Entry Point
  3. Running with mojo run
  4. Exploring in the Mojo REPL
← Back to Mojo Academy