Rust: Basic dependency tutorial Error

Hi community !

I’m going through the Rust tutorials and I’m stuck at the dependency one with this error at the dfx deploy stage :

I’ve followed the steps carefully, does anybody knows how I got this error ?

Thanks in advance.

More info :
dfx 0.8.4
ic-cdk = “0.4.0”
ic-cdk-macros = “0.4.0”


Not sure myself. Thanks for letting us know. Let me ping some folks i know are working on rust docs and SDK.

1 Like

Hi @dymayday,
ic-cdk v0.4 introduced a breaking change that candid should be included in your project Cargo.toml.

FYI, cdk-rs/ at main · dfinity/cdk-rs · GitHub

1 Like

Thank you @lwshang ,
I tried to add candid 0.7.11 as a dependency, but still having the same error.

Also, I took a look at the ic-cdk-macros repo, and I couldn’t find any import test overthere. Maybe it’s an overlooked bug :man_shrugging:

Yes, I can reproduce the problem.
I’m still investigating the reason of it. Will get back to you when we have a fix.

Thanks for reporting!


I encountered a similar problem when I mixed rust + motoko canister an.
At the beginning the project was simple (motoko only has one file), I add the motoko interface and then rust canister call new motoko interface, dfx deploy successful.
When Motoko canister were complicated ( There are multiple mo files and there is an import relationship), after adding a new interface in rust canister to call motoko canister, and then executing dfx deploy, an error similar to that will occur.

source repo: GitHub - lshoo/rust_deps: DFINITY rust + motoko project

If I only use (simple) instead of (complex) in the code repository , it can compile and deploy successfully, and what is even more strange is that complex can also be compiled and deployed successfully later.

Whenever I add a new function to rust canister and call the motoko canister function, I have two kinds of problems.

Operating environment: win10 + wsl2 (ubuntu 20.04)
dfx 0.9.0

1 Like

The fix of this issue is included in dfx version 0.9.2.
Could you (@dymayday & @lshoo) install the new version and see if it works?

1 Like

Thank you @lwshang !
Using dfx 0.9.2, still having issues, but it’s a different one now :

From the code in the tuto :

use ic_cdk_macros::*;
use ic_cdk::export::candid;

#[import(canister = "multiply_deps")]
struct CounterCanister;

async fn read() -> candid::Nat {
1 Like

I just went through the tutorial with dfx 0.9.2 and it works as expected.
Could you start a fresh new project and follow the tutorial again?

P.S. If you kept "dfx": "0.8.4" in dfx.json, it will actually use the specified version of dfx to build your canister instead of the latest version. I would recommend to copy/paste the final output of dfx.json as described in the tutorial.

1 Like

All good ! Thanks for the fix ! I don’t know what went wrong, but starting from fresh solved the issue.
PS : I did not have the dfx version in the dfx.json but it still failed.

@lwshang Thanks!
The problem still exists, when multipy_deps has only one mo file, both multiply_deps and rust_deps can be compiled and deployed successfully, but after multiply_deps has multiple mo files, 90% of rust_deps often fail to compile, even if it can be successfully compiled occasionally, when a new method is added to rust_deps , it will also fail.
Do you try to compile and deploy this repo: GitHub - lshoo/rust_deps: DFINITY rust + motoko project?
dfx 0.9.2
windows10 + wsl2 (ubuntu20.04)


1 Like

When I updated the rust sdk to 0.5, the compilation error still exists。
@lwshang ang

Hi @lshoo, currently import doesn’t work for all candid types. When the did file get more complicated, it may trigger the “not implemented” panic.

Could you try didc bind ecdsa.did -t rs , and use the generated rs binding? didc can be found at candid repo. Note that, you will need to get canister id from static env as in cdk-rs/ at main · dfinity/cdk-rs · GitHub.

This issue is on our plate. We are working on improving the developer experience about inter-canister operation.