A Rust client implementation of the Motoko package manger.
If you have many packages from github, you may get rate limited from github. You can create a personal access token, and put the token in the GITHUB_TOKEN
environment variable to get a much higher limit.
- Cache directory:
~/.mops/
, stores the Motoko compiler binary and library dependencies downloaded from mops or github. It can be changed by using the--cache-dir
flag. - Project root directory: The first occurance of
mops.toml
from the current directory to its parent directories. Ifmops.toml
is missing, the current directory is the root directory, and amops.toml
will be auto-generated. - Main Motoko file:
mops-cli build <main_file>
. If<main_file>
is omitted, will usemain.mo
orMain.mo
. - Build artifacts: Stored in
<root_directory>/target/<name>/<name>.wasm
, where<name>
can be specified bymops-cli build --name <name>
. If--name
is omitted,<name>
will be the filename of the main Motoko file. If the filename isMain.mo
ormain.mo
,<name>
will be the parent directory name. If anything fails, we usewasm
as the default<name>
. - Compiler flags:
--release --idl --stable-types --public-metadata candid:service -o target/<name>/<name>.wasm --package <from_mops_lock>
. If extra arguments are passed viamops-cli build -- <moc_args>
, the default flags will be dropped, except-o and --package
flags. If<moc_args>
contains-o
, the default-o
flag will be dropped.
import Backend "ic:ryjl3-tyaaa-aaaaa-aaaba-cai"
adds the following section
[[canister]]
canister_id = "ryjl3-tyaaa-aaaaa-aaaba-cai"
import Backend "canister:backend"
can be configured as
[[canister]]
name = "backend"
canister_id = "ryjl3-tyaaa-aaaaa-aaaba-cai"
import Type "./BackendType"
can be generated by
[[canister]]
candid = "Backend.did"
output = "BackendType.mo"
Differences from the node client
mops.toml
can be auto-generated frommain.mo
if the packages are all on mops.- Similar to
cargo build
,mops build
generates amops.lock
file that records the precise dependencies of the project. Note that the lock file format is different from the node client. mops build
can automatically download external dependencies specified inmops.lock
, without the need to runmops install
.- The downloaded packages are stored globally at
$HOME/.mops
, similar to cargo. - Overall, users can run
mops build main.mo
directly without any setup.
- Resolving package versions. Currently, we choose the largest version when package names collide, and errors out when we cannot decide on the version of a package. We need compiler support to allow the same package name to apply to different modules, and follow semantic versioning. The base library also need to follow semantic versioning.
- Removing a dependency doesn't remove the entries in
mops.lock