Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust-analyzer fails with ic_cdk_bindgen #442

Open
letmejustputthishere opened this issue Nov 5, 2023 · 3 comments
Open

rust-analyzer fails with ic_cdk_bindgen #442

letmejustputthishere opened this issue Nov 5, 2023 · 3 comments
Assignees

Comments

@letmejustputthishere
Copy link
Member

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
Copy link
Contributor

lwshang commented Nov 6, 2023

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

@letmejustputthishere
Copy link
Member Author

letmejustputthishere commented Mar 6, 2024

i guess this is related.

  • run dfx generate
  • run cargo build --target wasm32-unknown-unknown --release -p token_transfer_backend --locked --offline
Compiling token_transfer_backend v0.1.0 (/Users/moritz/projects/examples/rust/token_transfer/src/token_transfer_backend)
error: failed to run custom build command for `token_transfer_backend v0.1.0 (/Users/moritz/projects/examples/rust/token_transfer/src/token_transfer_backend)`

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
Copy link
Member Author

any news here? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants