Skip to content

Mojo Upgrading Between Versions

Mojo still changes from one release to the next. Since 1.0 the changes are calmer than before, but code from 2024 or early 2025 often doesn’t build at all on 1.2. This page shows how to keep a project on one known version, how to move it to a newer one, where to read what changed, and how to turn old Mojo syntax into today’s.

Ask the compiler:

Terminal window
mojo --version
Mojo 1.2.0 (2016d0cd)

Inside a uv project, run it through uv so you see the project’s own copy: uv run mojo --version. Every lesson on this site was tested with Mojo 1.2.0.

Mojo follows semantic versioning for the parts that are marked stable. The official stability guarantees page explains the details. In short:

  • Major versions (1.0, 2.0) can break code.
  • Minor versions (1.1, 1.2) add things in a backward-compatible way.
  • Patch versions (1.2.1) fix bugs.

The catch is the word “stable”. Most of the core language (control flow, types, ownership, __init__, __deinit__) is stable. But only a small part of the standard library is marked stable so far, and everything else can still change. In practice, both 1.1 and 1.2 removed old names. So treat every upgrade as a small job: read the notes, run your tests.

When you run uv add mojo, uv writes a lower bound like mojo>=1.2.0 into pyproject.toml, and records the exact version it installed in uv.lock. That lock file is what keeps everyone on the same version, so commit both files.

If you want the version written down in plain sight, pin it exactly:

Terminal window
uv add "mojo==1.2.0"

Now pyproject.toml says:

dependencies = [
"mojo==1.2.0",
]

uv swaps the installed packages to match. Here’s the real output when we moved a project from 1.1.0 to 1.2.0 this way (trimmed):

Resolved 10 packages in 7ms
Uninstalled 5 packages in 5ms
Installed 5 packages in 9ms
- mojo==1.1.0
+ mojo==1.2.0
- mojo-compiler==1.1.0
+ mojo-compiler==1.2.0

The mojo package pulls in a few others (mojo-compiler, its libraries and the formatter), and uv keeps them all in step.

How you upgrade depends on how you pinned:

  • Exact pin (mojo==1.2.0): change the pin. uv add "mojo==1.3.0" when a new version is out.
  • Lower bound (mojo>=1.2.0): ask uv to look for the newest allowed version and update the lock file:
Terminal window
uv lock --upgrade-package mojo
Resolved 10 packages in 86ms
Updated mblack v26.6.0 -> v26.7.0
Updated mojo v1.1.0 -> v1.2.0
Updated mojo-compiler v1.1.0 -> v1.2.0
Updated mojo-compiler-mojo-libs v1.1.0 -> v1.2.0
Updated mojo-lldb-libs v1.1.0 -> v1.2.0

That only changes uv.lock. uv sync installs it, and uv run does the same automatically before it runs anything.

Going back works the same way: uv add "mojo==1.1.0" puts the old version back if an upgrade breaks something and you need time to fix it.

Every release has its own page under Mojo releases. Each one has the same sections: Highlights, Language enhancements, Language changes, Library changes, Tooling changes, Removed and Fixed. Before you upgrade, read Highlights and Removed at least. That’s where the things that break your build are.

Recent releases (dates from PyPI):

Version Released Notes
1.0.0 2026-08-11 Release notes
1.1.0 2026-09-17 Release notes
1.2.0 2026-10-22 Release notes

There’s also a nightly page for changes that haven’t been released yet. Our Mojo Roadmap page sums up what’s planned.

Mojo usually removes things in two steps. First a release deprecates the old form: it still builds, but you get a warning, often with the fix printed right under it. A later release removes it, and then it’s an error.

Here’s a deprecated form in 1.2. The program still runs:

struct Ticket:
var id: Int
def __init__(out self, id: Int):
self.id = id
def __del__(deinit self):
print("closing ticket", self.id)
def main():
var t = Ticket(7)
print("working on", t.id)

Output:

working on 7
closing ticket 7

The compiler also prints this warning, with the new name under the old one:

ticket.mojo:7:9: warning: '__del__' is deprecated; use '__deinit__'
def __del__(deinit self):
^~~~~~~
__deinit__

And here’s a removed form. fn was deprecated in 1.0 and removed in 1.1, so now it’s an error, but the fix is still shown:

fn add(a: Int, b: Int) -> Int:
return a + b
def main():
print(add(2, 3))
add.mojo:1:1: error: 'fn' has been removed; use 'def' instead
fn add(a: Int, b: Int) -> Int:
^~
def
mojo: error: failed to parse the provided Mojo source module

We compiled the old form and the new form of every row on Mojo 1.2. The last column is what the old form does now.

Old Mojo 1.2 Old form on 1.2
fn add(...) def add(...) Error: “‘fn’ has been removed; use ‘def’ instead”
alias N = 5 comptime N = 5 Error (an unhelpful one: “expressions must not appear at file scope”)
let x = 5 var x = 5 Error: “use of unknown declaration ‘let’”
x = 5 for a new name var x = 5 Error: “implicit declaration of ‘x’ is not allowed”
inout x: Int mut x: Int Error: “expected ‘)’ in argument list”
owned s: String var s: String Error: “expected ‘)’ in argument list”
borrowed s: String s: String (read-only is the default) Error: “expected ‘)’ in argument list”
read s: String s: String, or imm s: String to say it Error: “‘read’ was removed; use ‘imm’”
def __del__(owned self) def __deinit__(deinit self) __del__ warns “deprecated”; owned is an error
@value struct P: @fieldwise_init struct P(Copyable): Error: “use of unknown declaration ‘value’”
@parameter if / @parameter for comptime if / comptime for Error: “‘if’ statement does not support decorators”
__copyinit__(out self, other: Self) __init__(out self, *, copy: Self) Not special any more: old code fails to build
__moveinit__(out self, owned other: Self) __init__(out self, *, deinit move: Self) Error, because of owned
@register_passable("trivial") conform to TrivialRegisterPassable Error: “decorator @register_passable(“trivial”) is removed“
struct P(Stringable) with __str__ struct P(Writable) with write_to Error: “use of unknown declaration ‘Stringable’”
UnsafePointer(to=x) Pointer(to=x) Warning: “‘UnsafePointer’ is deprecated, use ‘Pointer’ instead”
InlineArray[Int, 3] Array[Int, 3] Error: “use of unknown declaration ‘InlineArray’”
mojo package lib -o lib.mojopkg mojo precompile lib -o lib.mojoc package warns “deprecated”; a .mojopkg path is refused: “output path must have a ‘.mojoc’ extension”
magic add mojo uv add mojo or pixi add mojo magic is deprecated

Two rows need a word more. @value used to add an initializer and copy and move support. In 1.2 @fieldwise_init adds the initializer, and you list the traits you want (Copyable, plus Writable if you want to print it). And owned had two different jobs: in arguments it became var, in a destructor it became deinit.

This program was fine Mojo a couple of years ago:

alias GREETING = "Hello"
@value
struct Counter:
var count: Int
fn bump(inout self):
self.count += 1
fn main():
var c = Counter(0)
c.bump()
print(GREETING, c.count)

On 1.2 the compiler stops at the first line:

counter.mojo:1:1: error: expressions must not appear at file scope; move this into a function body
alias GREETING = "Hello"
^
counter.mojo:1:7: error: statements must start at the beginning of a line
alias GREETING = "Hello"
^
mojo: error: failed to parse the provided Mojo source module

The message doesn’t mention alias at all, because to the parser alias is now just an unknown word. That’s why a table like the one above is handy. Fix the file top to bottom, one row at a time:

comptime GREETING = "Hello"
@fieldwise_init
struct Counter(Copyable):
var count: Int
def bump(mut self):
self.count += 1
def main():
var c = Counter(0)
c.bump()
print(GREETING, c.count)

Output:

Hello 1

Four changes: alias to comptime, @value to @fieldwise_init plus Copyable, fn to def and inout to mut.

This function was written for an older Mojo. Make it build and run on 1.2.

fn add_tax(inout price: Float64, owned label: String):
price = price * 1.2
print(label, price)
fn main():
var p = 10.0
add_tax(p, "Total:")

Hint: three keywords need to change. Use the table.

Show solution
def add_tax(mut price: Float64, var label: String):
price = price * 1.2
print(label, price)
def main():
var p = 10.0
add_tax(p, "Total:")

Output:

Total: 12.0

fn became def, inout became mut (the function changes the caller’s p) and owned became var (the function gets its own copy of the label).

Bring this struct up to date. Keep the clean-up message.

alias LIMIT = 3
@value
struct Job:
var id: Int
fn __del__(owned self):
print("job", self.id, "done")
fn main():
var j = Job(LIMIT)
print("running job", j.id)

Hint: the destructor has a new name and a new argument convention.

Show solution
comptime LIMIT = 3
@fieldwise_init
struct Job:
var id: Int
def __deinit__(deinit self):
print("job", self.id, "done")
def main():
var j = Job(LIMIT)
print("running job", j.id)

Output:

running job 3
job 3 done

__del__(owned self) is now __deinit__(deinit self). The struct doesn’t need Copyable because nothing copies it; add it only when you need .copy().

  • Check your version with mojo --version (or uv run mojo --version in a project).
  • Commit uv.lock; pin exactly with uv add "mojo==1.2.0" if you want it visible.
  • Upgrade by changing the pin, or with uv lock --upgrade-package mojo for a >= bound.
  • Read Highlights and Removed in the release notes before you upgrade.
  • Old forms are deprecated first (warning plus fix-it), then removed (error).
  • The big renames: fn→def, alias→comptime, inout→mut, owned→var/deinit, @value→@fieldwise_init, __del__→__deinit__.

Next up: documentation, writing docstrings for your own code and turning them into docs with mojo doc.

Quick check

1. Your project has mojo>=1.1.0 in pyproject.toml. Which command moves the lock file to the newest allowed Mojo?
2. What does inout x: Int become in Mojo 1.2?
3. An old file starts with alias SIZE = 10 and fails with "expressions must not appear at file scope". What is the fix?