Mops CLI
Opinionated guide for Motoko projects. Covers project config, dependency management, type-checking, building, and linting.
Key Principles
- No dfx — mops neither invokes nor supports
dfx. There is nomops toolchain init, nomoc-wrapper, and nomops watch --generate/--deploy. Always pinmocin[toolchain]; every command that compiles requires it. Use the newestmocversion. Pinpocket-ictoo if you have replica tests, benchmarks, or--check-deploy— with no pin those commands error, namingmops toolchain use pocket-ic 15.0.0. WhenMOPS_POCKET_IC_URLpoints at an already-running PocketIC server, no pin is needed and an existing pin is ignored with a warning — do not add one to silence it; unset the variable instead. - No
mo:base— it is deprecated. Always usemo:core(import Array "mo:core/Array"). - All config in
mops.toml— canisters, moc flags, toolchain versions, build settings. - Canister-centric workflow — define all canisters in
[canisters]; never pass file paths tomops check. Exception: library packages (no[canisters]) use file paths directly:mops check src/**/*.mo.
Project Setup
Minimal `mops.toml`
[toolchain]
moc = "1.15.1"
lintoko = "0.11.0"
pocket-ic = "15.0.0" # required for replica tests / benchmarks / --check-deploy
[dependencies]
core = "2.6.1"
[moc]
args = ["--default-persistent-actors", "-W=M0223,M0236,M0237"]
[canisters.backend]
main = "src/backend/main.mo"
[canisters.backend.migrations]
chain = "src/backend/migrations"
# check-limit = 10 # optional — speeds up `mops check` when the chain gets long
[canisters.backend.check-stable]
path = "deployed/backend.most"
[build]
outputDir = "src/backend/dist"
args = ["--release"]
# check-wasm = true # optional: analyze final Wasm complexity
# check-deploy = true # optional: verify fresh PocketIC installation after build
# Opt-in Wasm optimization (Binaryen wasm-opt) for build + bench
[optimize]
# level = "O3" # default
# keep-names = true # default
# wasm-opt pin: [toolchain] wasm-opt = "131" (required when [optimize] is set)
check-stable runs ICP's upgrade-time stable-variable compatibility check locally, so incompatible changes fail in mops check instead of being rejected when upgrading a live canister. It compares the current code against a .most from the deployed version.
Bootstrap that .most: new project → mops deployed init (empty-actor baseline); already-deployed canister → build from the deployed commit, then mops deployed. After every deploy, run mops deployed to promote the just-built .most (see