I’m trying to add an ICRC token canister to an existing project that has other canisters.
I added the token canister to dfx.json, installed mops, and on deploy of the ICRC token canister, I get
dfx deploy icrc_token
Deploying: icrc_token
All canisters have already been created.
Building canisters...
Error: Failed while trying to deploy canisters.
Caused by: Failed while trying to deploy canisters.
Failed to build call canisters.
Failed while trying to build all canisters.
The build step failed for canister 'rno2w-sqaaa-aaaaa-aaacq-cai' (icrc_token) with an embedded error: Failed to build Motoko canister 'icrc_token'.: Failed to compile Motoko.: Failed to run 'moc'.: The command '"/Users/black/.cache/dfinity/versions/0.12.1/moc" "/Users/black/icp/b/backed_usd/src/icrc_token/Main.mo" "-o" "/Users/black/icp/b/backed_usd/.dfx/local/canisters/icrc_token/icrc_token.wasm" "-c" "--debug" "--idl" "--stable-types" "--public-metadata" "candid:service" "--actor-idl" "/Users/black/icp/b/backed_usd/.dfx/local/canisters/idl/" "--actor-alias" "icrc_token" "rno2w-sqaaa-aaaaa-aaacq-cai" "--package" "base" ".mops/base@0.7.4/src" "--package" "xtended-numbers" ".mops/xtended-numbers@0.1.1/src" "--package" "itertools" ".mops/itertools@0.1.1/src"' failed with exit status 'exit status: 1'.
Stdout:
Stderr:
/Users/black/icp/b/icrc1/src/ICRC1/lib.mo:16.1-16.40: import error [M0010], package "StableTrieMap" not defined
This is Main.mo in src/icrc_token in my project’s repo (I just pasted it verbatim for now): icrc1/main.mo at main · NatLabs/icrc1 · GitHub
The error arises here: icrc1/lib.mo at c9ff6c64ee1531f33bf3d4d43bcbbbed271008af · NatLabs/icrc1 · GitHub
It seems to be a problem with mops. It’s not installing the packages.
This is my mops.toml
[dependencies]
base = "https://github.com/dfinity/motoko-base#moc-0.7.4"
array = "https://github.com/aviate-labs/array.mo#v0.2.0"
StableTrieMap = "https://github.com/NatLabs/StableTrieMap#main"
StableBuffer = "https://github.com/canscale/StableBuffer#v0.2.0"
xtended-numbers = "0.1.1"
itertools = "0.1.1"
[package]
name = "icrc1"
version = "0.1.0"
description = ""
repository = ""
and yet on deploy I get
Stdout:
Stderr:
(unknown location): package error [M0012], file ".mops/_github/StableBuffer@v0.2.0/src" (for package `StableBuffer`) does not exist
(unknown location): package error [M0012], file ".mops/_github/StableTrieMap@main/src" (for package `StableTrieMap`) does not exist
(unknown location): package error [M0012], file ".mops/_github/array@v0.2.0/src" (for package `array`) does not exist
@blabagastered what happens when you run mops install
in your project
1 Like
It seems there was something to it because I have two repos now. The main one, that includes the ICRC token canister and others, and a separate one that is only the ICRC token.
They had gotten muddled up and when I ran mops install
in the main one, it did install things. The other one had everything installed.
That allowed deployment of some of the canisters, but not of the ICRC token canister in the main repo. I got this error log:
black@MacBook-Pro backed_usd % dfx deploy backed_usd_icrc
Deploying: backed_usd_icrc
Creating canisters...
Creating canister backed_usd_icrc...
backed_usd_icrc canister created with canister id: rno2w-sqaaa-aaaaa-aaacq-cai
Building canisters...
Error: Failed while trying to deploy canisters.
Caused by: Failed while trying to deploy canisters.
Failed to build call canisters.
Failed while trying to build all canisters.
The build step failed for canister 'rno2w-sqaaa-aaaaa-aaacq-cai' (backed_usd_icrc) with an embedded error: Failed to build Motoko canister 'backed_usd_icrc'.: Failed to compile Motoko.: Failed to run 'moc'.: The command '"/Users/black/.cache/dfinity/versions/0.12.1/moc" "/Users/black/icp/b/backed_usd/src/backed_usd_icrc/Main.mo" "-o" "/Users/black/icp/b/backed_usd/.dfx/local/canisters/backed_usd_icrc/backed_usd_icrc.wasm" "-c" "--debug" "--idl" "--stable-types" "--public-metadata" "candid:service" "--actor-idl" "/Users/black/icp/b/backed_usd/.dfx/local/canisters/idl/" "--actor-alias" "backed_usd_icrc" "rno2w-sqaaa-aaaaa-aaacq-cai" "--package" "base" ".mops/_github/base@moc-0.7.4/src" "--package" "array" ".mops/_github/array@v0.2.0/src" "--package" "StableTrieMap" ".mops/_github/StableTrieMap@main/src" "--package" "StableBuffer" ".mops/_github/StableBuffer@v0.2.0/src" "--package" "xtended-numbers" ".mops/xtended-numbers@0.1.1/src" "--package" "itertools" ".mops/itertools@0.1.1/src"' failed with exit status 'exit status: 1'.
Stdout:
Stderr:
/Users/black/icp/b/icrc1/src/ICRC1/lib.mo:346.27-346.33: type error [M0097], expected function type, but expression produces type
Nat
/Users/black/icp/b/icrc1/src/ICRC1/lib.mo:346.33-346.34: info, this looks like an unintended function call, perhaps a missing ';'?
/Users/black/icp/b/icrc1/src/ICRC1/lib.mo:346.27-346.33: type error [M0097], expected function type, but expression produces type
Nat
/Users/black/icp/b/icrc1/src/ICRC1/lib.mo:346.33-346.34: info, this looks like an unintended function call, perhaps a missing ';'?
/Users/black/icp/b/icrc1/src/ICRC1/lib.mo:346.34-346.49: type error [M0057], unbound variable _FFFF_FFFF_FFFF
/Users/black/icp/b/icrc1/src/ICRC1/lib.mo:354.28-354.66: type error [M0096], expression of type
Nat__2
cannot produce expected type
None
The ICRC-only repo says just:
black@MacBook-Pro icrc1 % mops install
All packages installed
Found the problem:
Part of it was that mops install
hadn’t been run. There’s no explicit instruction to do it here GitHub - NatLabs/icrc1: A full implementation of the ICRC-1 fungible token standard nor in the mops instructions themselves: Internet Computer Content Validation Bootstrap, so I didn’t do it.
And part of it was that in trying to fix this file/line icrc1/lib.mo at c9ff6c64ee1531f33bf3d4d43bcbbbed271008af · NatLabs/icrc1 · GitHub I saved the file, and the auto-formatting-on-save tool I have (not sure which) broke the file on save.
I re-pasted the original lib.mo, saved it without formatting, and it now worked.
2 Likes