dfinity / sdk

IC SDK: a Software Development Kit for creating and managing canister smart contracts on the ICP blockchain.

Home Page:https://internetcomputer.org/developers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Candid file check failed: Cannot import

paulyoung opened this issue · comments

I recently started breaking up my Candid file into smaller files to make it more manageable.

For example, I moved everything related to Canistergeek to candid/canistergeek.did and now do import "canistergeek.did"; in candid/codebase.did.

My candid_interface_compatibility test (similar to this one) supports this, and now also my ic-repl tests (thanks to @chenyan2002 and dfinity/ic-repl#50)

However, dfx generate now fails.

I tried the following:

  1. dfx generate --verbose codebase_backend

I expected to see this happen:

Generating type declarations for canister codebase_backend:
  frontend/declarations/codebase_backend/codebase_backend.did.js

Instead, this happened:

Error: (BFailed while trying to generate type declarations for 'codebase_backend'.
Caused by: (BFailed while trying to generate type declarations for 'codebase_backend'.
  Candid file check failed for frontend/declarations/codebase_backend/codebase_backend.did.
    Cannot import "canistergeek.did"

sdk/src/dfx/src/util/mod.rs

Lines 144 to 152 in fc6d589

pub fn check_candid_file(idl_path: &std::path::Path) -> DfxResult<(TypeEnv, Option<Type>)> {
//context macro does not work for the returned error type
pretty_check_file(idl_path).with_context(|| {
format!(
"Candid file check failed for {}.",
idl_path.to_string_lossy()
)
})
}

Meta

dfx --version:

dfx 0.12.0-beta.3

@chenyan-dfinity Is this something that we can fix by upgrading Motoko?