thread 'main' panicked at 'Cannot find candid path: NotPresent', /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ic-cdk-bindgen-0.1.0/src/lib.rs:18:58
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
here is my build.rs
:
use ic_cdk_bindgen::{Builder, Config};
use std::path::PathBuf;
fn main() {
let manifest_dir =
PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").expect("Cannot find manifest dir"));
let cmc = Config::new("nns-cycles-minting");
let mut builder = Builder::new();
builder.add(cmc);
builder.build(Some(manifest_dir.join("declarations")));
}
here is my definition for transfer_handler
canister in dfx.json
:
"transfer_handler": {
"candid": "backend/transfer_handler/transfer_handler.did",
"package": "transfer_handler",
"declarations": {
"bindings": null,
"env_override": null,
"node_compatibility": false,
"output": "./frontend/********/src/declarations/transfer_handler/"
},
"type": "rust",
"dependencies": ["nns-cycles-minting", "internet_identity"]
},
I ran dfx deploy
on cdk-rs
’s example got the same error:
error: failed to run custom build command for `profile_inter_rs v0.1.0 (/root/projects/cdk-rs/examples/profile/src/profile_inter_rs)`
Caused by:
process didn't exit successfully: `/root/projects/cdk-rs/examples/profile/target/release/build/profile_inter_rs-e607a0e17669e753/build-script-build` (exit status: 101)
--- stderr
thread 'main' panicked at 'Cannot find candid path: NotPresent', /root/projects/cdk-rs/src/ic-cdk-bindgen/src/lib.rs:18:58
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
Error: Failed while trying to deploy canisters.
Caused by: Failed while trying to deploy canisters.
Failed to build all canisters.
Failed while trying to build all canisters.
The build step failed for canister 'bd3sg-teaaa-aaaaa-qaaba-cai' (profile_rs) with an embedded error: Failed to build custom canister profile_rs.: Failed to run sh ../build.sh profile profile_rs.: The custom tool failed.
(base) root@DESKTOP-D2P8H7D:~/projects/cdk-rs/examples/profile# dfx upgrade
Current version: 0.14.3
Fetching manifest https://sdk.dfinity.org/manifest.json
Already up to date
I can’t reproduce the error.
The error message “Cannot find candid path: NotPresent” informed that the required environment variable CANISTER_CANDID_PATH_<CANISTER_NAME>
was not set.
dfx
should be able to handle the env_var. I can’t tell why it’s not there.
I noticed that your project was in /root/
dir. Perhaps you are using root account. Not sure if it matters.
I just did an experiment using root account and saw the same error.
So there is some rule interfere env_var passing with root account.
Could you use a normal account on your machine instead of root?
Using root in dev enviroment has a lot of convenience. Why ic-cdk-bindgen
suck in this? I found the user custom canister in dfx.json
works for ic-cdk-bindgen, such as the below canister:
"****": {
"candid": "backend/non_fiction_books/****.did",
"declarations": {
"bindings": null,
"env_override": null,
"node_compatibility": false,
"output": "./frontend/ic_library/src/declarations/****/"
},
"wasm": "./target/wasm32-unknown-unknown/release/****.wasm.gz",
"type": "custom"
},
but dfx auto gen canisters not work for ic-cdk-bindgen
:
"nns-cycles-minting": {
"build": "",
"candid": "candid/nns-cycles-minting.did",
"remote": {
"id": {
"ic": "rkp4c-7iaaa-aaaaa-aaaca-cai",
"local": "rkp4c-7iaaa-aaaaa-aaaca-cai"
}
},
"type": "custom",
"wasm": ""
},