dfinity / cdk-rs

Rust canister development kit for the Internet Computer.
Apache License 2.0
199 stars 85 forks source link

`rust-analyzer` fails with `ic_cdk_bindgen` #442

Open letmejustputthishere opened 10 months ago

letmejustputthishere commented 10 months ago

it seems like ic_cdk_bindgen expects an env variable set for the candid path. if you're not building with dfx, the env variables doens't seem to be present and the rust-analyzer VSCode plugin throws the following error:

[ERROR rust_analyzer::main_loop] FetchBuildDataError:
error: failed to run custom build command for `iluvatar_backend v0.1.0 (/Users/moritz/projects/iluvatar/src/iluvatar_backend)`
note: To improve backtraces for build dependencies, set the CARGO_PROFILE_DEV_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.

Caused by:
  process didn't exit successfully: `/Users/moritz/projects/iluvatar/target/debug/build/iluvatar_backend-0919ac66e4da000e/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at /Users/moritz/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ic-cdk-bindgen-0.1.1/src/lib.rs:18:58:
  Cannot find candid path: NotPresent
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:595:5
     1: core::panicking::panic_fmt
               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/panicking.rs:67:14
     2: core::result::unwrap_failed
               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/result.rs:1652:5
     3: core::result::Result<T,E>::expect
     4: ic_cdk_bindgen::Config::new
     5: build_script_build::main
     6: core::ops::function::FnOnce::call_once
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
lwshang commented 10 months ago

Thanks for reporting. Will let you know when we fix it.

letmejustputthishere commented 6 months ago

i guess this is related.

Caused by: process didn't exit successfully: /Users/moritz/projects/examples/rust/token_transfer/target/release/build/token_transfer_backend-ba044735f0bc079b/build-script-build (exit status: 101) --- stderr thread 'main' panicked at /Users/moritz/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ic-cdk-bindgen-0.1.3/src/lib.rs:63:9: Cannot find environment variable: CANISTER_CANDID_PATH_ICRC1_LEDGER_CANISTER note: run with RUST_BACKTRACE=1 environment variable to display a backtrace


the content of the `.env` file is as follows

DFX CANISTER ENVIRONMENT VARIABLES

DFX_VERSION='0.17.0' DFX_NETWORK='local' ICRC1_LEDGER_CANISTER_CANISTER_ID='bkyz2-fmaaa-aaaaa-qaaaq-cai' CANISTER_ID_ICRC1_LEDGER_CANISTER='bkyz2-fmaaa-aaaaa-qaaaq-cai' CANISTER_ID_icrc1_ledger_canister='bkyz2-fmaaa-aaaaa-qaaaq-cai' CANISTER_ID='bkyz2-fmaaa-aaaaa-qaaaq-cai' CANISTER_CANDID_PATH='/Users/moritz/projects/examples/rust/token_transfer/.dfx/local/canisters/icrc1_ledger_canister/icrc1_ledger_canister.did'

END DFX CANISTER ENVIRONMENT VARIABLES

letmejustputthishere commented 3 months ago

any news here? :)