dfinity / sdk

IC SDK: a Software Development Kit for creating and managing canister smart contracts on the ICP blockchain.
https://internetcomputer.org/docs/current/home
Apache License 2.0
178 stars 86 forks source link

Upgrading to DFX 0.23.0 failing to build canisters - No crate X found #3919

Closed KereyWatters closed 2 months ago

KereyWatters commented 2 months ago

Although there aren't any breaking changes, when upgrading from 0.22.0 to 0.23.0 my project is no longer able to build:

Error: Failed while trying to build all canisters.
Caused by: The build step failed for canister 'bkyz2-fmaaa-aaaaa-qaaaq-cai' (zk-rust-vue-demo-backend)
Caused by: Failed to build Rust canister 'zk-rust-vue-demo-backend'.
Caused by: Failed to create <Type>CanisterInfo for canister 'zk-rust-vue-demo-backend'.
Caused by: No crate `zk-rust-vue-demo-backend` found

Here is my DFX file:

{
    "canisters": {
        "internet-identity": {
            "type": "pull",
            "id": "rdmx6-jaaaa-aaaaa-aaadq-cai"
        },
        "zk-rust-vue-demo-backend": {
            "dependencies": [
              "internet-identity"
            ],
            "candid": "src/zk-rust-vue-demo-backend/zk-rust-vue-demo-backend.did",
            "package": "zk-rust-vue-demo-backend",
            "type": "rust"
        },
        "zk-rust-vue-demo-frontend": {
            "dependencies": [
                "zk-rust-vue-demo-backend"
            ],
            "source": [
                "src/zk-rust-vue-demo-frontend/dist"
            ],
            "type": "assets",
            "workspace": "zk-rust-vue-demo-frontend"
        }
    },
    "defaults": {
        "build": {
            "args": "",
            "packtool": ""
        }
    },
    "output_env_file": ".env",
    "version": 1
}

Meta

dfx --version:

0.22.0 upgrading to 0.23.0
Further log output

``` Building canisters... Checking for vulnerabilities in rust canisters. Fetching advisory database from `https://github.com/RustSec/advisory-db.git` Loaded 659 security advisories (from /home/kairus/.cargo/advisory-db) Updating crates.io index Scanning Cargo.lock for vulnerabilities (79 crate dependencies) Audit found no vulnerabilities. Building frontend... Running cd "/mnt/c/Users/Kairus/git/IC/zk-rust-vue-demo" && CANISTER_CANDID_PATH="/mnt/c/Users/Kairus/git/IC/zk-rust-vue-demo/.dfx/local/canisters/zk-rust-vue-demo-frontend/assetstorage.did" CANISTER_ID="bd3sg-teaaa-aaaaa-qaaba-cai" CANISTER_ID_INTERNET_IDENTITY="rdmx6-jaaaa-aaaaa-aaadq-cai" CANISTER_ID_ZK_RUST_VUE_DEMO_BACKEND="bkyz2-fmaaa-aaaaa-qaaaq-cai" CANISTER_ID_ZK_RUST_VUE_DEMO_FRONTEND="bd3sg-teaaa-aaaaa-qaaba-cai" DFX_NETWORK="local" DFX_VERSION="0.23.0" "npm" "run" "build" "--workspace" "zk-rust-vue-demo-frontend"... WARN: Generating type declarations for canister zk-rust-vue-demo-frontend: /mnt/c/Users/Kairus/git/IC/zk-rust-vue-demo/src/declarations/zk-rust-vue-demo-frontend/zk-rust-vue-demo-frontend.did.d.ts /mnt/c/Users/Kairus/git/IC/zk-rust-vue-demo/src/declarations/zk-rust-vue-demo-frontend/zk-rust-vue-demo-frontend.did.js /mnt/c/Users/Kairus/git/IC/zk-rust-vue-demo/src/declarations/zk-rust-vue-demo-frontend/zk-rust-vue-demo-frontend.did Generating type declarations for canister zk-rust-vue-demo-backend: /mnt/c/Users/Kairus/git/IC/zk-rust-vue-demo/src/declarations/zk-rust-vue-demo-backend/zk-rust-vue-demo-backend.did.d.ts /mnt/c/Users/Kairus/git/IC/zk-rust-vue-demo/src/declarations/zk-rust-vue-demo-backend/zk-rust-vue-demo-backend.did.js /mnt/c/Users/Kairus/git/IC/zk-rust-vue-demo/src/declarations/zk-rust-vue-demo-backend/zk-rust-vue-demo-backend.did Generating type declarations for canister internet-identity: /mnt/c/Users/Kairus/git/IC/zk-rust-vue-demo/src/declarations/internet-identity/internet-identity.did.d.ts /mnt/c/Users/Kairus/git/IC/zk-rust-vue-demo/src/declarations/internet-identity/internet-identity.did.js /mnt/c/Users/Kairus/git/IC/zk-rust-vue-demo/src/declarations/internet-identity/internet-identity.did Error: Failed while trying to build all canisters. Caused by: The build step failed for canister 'bkyz2-fmaaa-aaaaa-qaaaq-cai' (zk-rust-vue-demo-backend) Caused by: Failed to build Rust canister 'zk-rust-vue-demo-backend'. Caused by: Failed to create CanisterInfo for canister 'zk-rust-vue-demo-backend'. Caused by: No crate `zk-rust-vue-demo-backend` found ```

wiyota commented 2 months ago

This seems to be a problem associated with the following changes https://github.com/dfinity/sdk/pull/3836

This can be worked around by changing hyphens in name of the crate to underscores.

Since hyphens are not used as identifiers inside Rust, I assume this is due to the conversion of hyphens to underscores, but if this side effect is unintentional, it needs to be fixed.