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.
Which version do you have?
Section titled “Which version do you have?”Ask the compiler:
mojo --versionMojo 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.
What 1.x promises
Section titled “What 1.x promises”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.
Pin a version with uv
Section titled “Pin a version with uv”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:
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 7msUninstalled 5 packages in 5msInstalled 5 packages in 9ms - mojo==1.1.0 + mojo==1.2.0 - mojo-compiler==1.1.0 + mojo-compiler==1.2.0The mojo package pulls in a few others (mojo-compiler, its libraries and the formatter), and uv keeps them all in step.
Upgrade
Section titled “Upgrade”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:
uv lock --upgrade-package mojoResolved 10 packages in 86msUpdated mblack v26.6.0 -> v26.7.0Updated mojo v1.1.0 -> v1.2.0Updated mojo-compiler v1.1.0 -> v1.2.0Updated mojo-compiler-mojo-libs v1.1.0 -> v1.2.0Updated mojo-lldb-libs v1.1.0 -> v1.2.0That 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.
Where to read what changed
Section titled “Where to read what changed”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.
How old syntax goes away
Section titled “How old syntax goes away”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 7closing ticket 7The 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' insteadfn add(a: Int, b: Int) -> Int:^~defmojo: error: failed to parse the provided Mojo source moduleOld syntax and its 1.2 replacement
Section titled “Old syntax and its 1.2 replacement”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.
A small migration, start to finish
Section titled “A small migration, start to finish”This program was fine Mojo a couple of years ago:
alias GREETING = "Hello"
@valuestruct 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 bodyalias GREETING = "Hello"^counter.mojo:1:7: error: statements must start at the beginning of a linealias GREETING = "Hello" ^mojo: error: failed to parse the provided Mojo source moduleThe 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_initstruct 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 1Four changes: alias to comptime, @value to @fieldwise_init plus Copyable, fn to def and inout to mut.
Practice
Section titled “Practice”1. Update a function
Section titled “1. Update a function”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.0fn 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).
2. Update a struct
Section titled “2. Update a struct”Bring this struct up to date. Keep the clean-up message.
alias LIMIT = 3
@valuestruct 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_initstruct 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 3job 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(oruv run mojo --versionin a project). - Commit
uv.lock; pin exactly withuv add "mojo==1.2.0"if you want it visible. - Upgrade by changing the pin, or with
uv lock --upgrade-package mojofor 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
Section titled “Quick check”Quick check
Read more
Section titled “Read more”- Mojo releases: the release notes for every version, including the nightly changes.
- Mojo 1.0 release notes: the big rename release, with most of the changes in the table above.
- Mojo stability guarantees: what 1.x promises and which features are still internal.
- Install Mojo: the current install commands for uv and pixi.
- uv: managing dependencies: how uv handles version bounds, pins and upgrades.