I have a workspace with 3 crates, game_nft, backend and tests.
Here is my root Cargo.toml
[workspace]
members = ["backend", "game_nft", "tests"]
resolver = "2"
My tests/Cargo.toml:
[package]
name = "tests"
version = "0.1.0"
edition = "2021"
[lib]
crate-type = ["cdylib"]
[dependencies]
candid = "0.10.6"
pocket-ic = "6.0.0"
game_nft = { path = "../game_nft" }
To be very clear, here is the file structure:
root/
├── Cargo.toml
├── Cargo.lock
├── game_nft/
│ ├── Cargo.toml
│ └── src/
├── test/
│ ├── Cargo.toml
│ └── src/
├── backend/
├── Cargo.toml
└── src/
In my tests/src/lib.rs I do use game_nft;
So why am I getting the error:
error[E0432]: unresolved import `game_nft`
--> tests/src/lib.rs:3:5
|
3 | use game_nft;
| ^^^^^^^^ no external crate `game_nft`
Here is game_nft/Cargo.toml:
[package]
name = "game_nft"
version = "0.1.0"
edition = "2021"
[lib]
crate-type = ["cdylib"]
[dependencies]
candid = "0.10.6"
ic-cdk = "0.13.1"
ic-stable-structures = "0.6.3"
icrc-ledger-types = "0.1.5"
serde = "1.0.197"
icrc-nft-types = { git = "https://github.com/pramitgaha21/icrc-nft-types.git" }
ciborium = "0.2.2"
serde_bytes = "0.11"
I have also tried the syntax use crate::game_nft;
and got the same error message.
A cdylib
cannot be used from Rust. You can make game_nft
(at least) of type lib
, dylib
, or rlib
. You can read more about these here.
So game_nft/Cargo.toml
should read:
crate-type = ["cdylib", "lib"]