Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

migrating-to-moc-2

БесплатноБез исполняемых скриптовНе проверен

Move a Motoko project from moc 1 to moc 2 — toolchain bump, removed compiler flags, and the fix for every new error. Load when bumping the moc toolchain to a…

jiayaoqijiaот jiayaoqijia★ 81 звезда на GitHub

Об этом скилле

Migrating to moc 2

moc 2 is a major release of the Motoko compiler. It changes four things:

  • Persistence. Actors are persistent by default. Enhanced orthogonal persistence (EOP) is the only memory model and the incremental GC the only collector.
  • Strictness. Warnings for code that traps or silently does not do what it says are now errors, and a pattern must fit the type it matches.
  • Syntax. A few moc 1 forms no longer parse (a ??b, a branch glued to its condition, flexible). Several lighter forms are new and optional.
  • Flags. Every flag of a removed feature is rejected as an unknown option.

Most projects need a handful of edits, and the compiler names each one. This skill maps every diagnostic to its fix. The upstream moc 1 → 2 migration guide has longer explanations, and the release notes list each change per release.

First: is any canister still on classical persistence?

moc 2 cannot build a canister on classical (32-bit) persistence, but it can upgrade one to EOP. A deployed canister is classical if it was built with --legacy-persistence, with a non-incremental GC flag (--copying-gc, --compacting-gc, --generational-gc), or with a moc older than 0.15, where classical was the default.

  • Move it to EOP: compile that one upgrade with --enhanced-orthogonal-persistence and without --enhanced-migration. The move is irreversible; later upgrades need neither flag. Without the flag the upgrade traps ("Detected implicit upgrade from classical orthogonal persistence to enhanced orthogonal persistence"); with --enhanced-migration it traps too ("Cannot upgrade from classical orthogonal persistence with --enhanced-migration").
  • Keep it classical: stay on moc 1.

A canister that moved to EOP with a moc older than 1.5.0 can trap on a later upgrade with cannot upgrade from an actor using enhanced migration to an actor not using enhanced migration. Run that one upgrade with graph-copy stabilization; the upstream EOP migration path has the steps.

Every other canister already runs on EOP and needs no persistence work.

Checklist

  1. Build cleanly on the latest moc 1 first. The .vals() (M0269) and preupgrade/postupgrade (M0270) deprecations are identical in moc 2, so fix them before switching; on moc 2, mops check --fix rewrites .vals() to .values(). Fix every warning in the diagnostics table too — most become errors.
  2. Bump the toolchain to the latest 2.x release: mops toolchain use moc <version> (it rewrites [toolchain] moc in mops.toml), or wherever your build pins moc.
  3. Delete the removed flags from [moc].args, [build].args, [canisters.<name>].args, dfx.json and build scripts.
  4. Run mops check and fix what it reports in this order, because earlier errors hide later ones:
    1. syntax errors (??, glued branches, flexible, record literals in block position);
    2. errors that were warnings in moc 1;
    3. M0277, redundant async on a function body;
    4. M0142 and M0193 in libraries and actor classes;
    5. M0131, only if you built with --legacy-actors.
  5. Check upgrade compatibility against the deployed version before upgrading a live canister: mops check-stable, or moc --stable-compatible old.most new.most. Removing persistent and stable keywords does not change the stable signature.
  6. Optionally adopt the moc 2 forms — only once nothing builds this code with moc 1 anymore. See After the switch.

Removed flags

moc 2 exits with unknown option '<flag>' on each of these.

Flag Replacement
--default-persistent-actors, --require-persistent-actors none needed: actors are persistent by default
--legacy-actors mark every field that should reset on upgrade transient
--legacy-persistence, --copying-gc, --compacting-gc, --generational-gc none: stay on moc 1 for classical canisters
--incremental-gc, --rts-stack-pages, --skip-gc-deprecation-warning, --experimental-rtti none needed
`--experiment
Полный SKILL.md на GitHub

Установить migrating-to-moc-2 в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

LICENSESOURCE.mdTRUST.auto.yaml

FAQ

Что делает скилл migrating-to-moc-2?

Move a Motoko project from moc 1 to moc 2 — toolchain bump, removed compiler flags, and the fix for every new error. Load when bumping the moc toolchain to a 2.x release, when code that built on moc 1 fails on moc 2, or when one codebase must compile with both.

Как установить скилл migrating-to-moc-2?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл migrating-to-moc-2 запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить migrating-to-moc-2 с