# Error: \`principal\` must be defined only once in the type namespace of this module

**URL:** <https://forum.dfinity.org/t/error-principal-must-be-defined-only-once-in-the-type-namespace-of-this-module/17286>\
**Category:** Developers\
**Created:** [December 10, 2022, 3:09pm UTC](https://forum.dfinity.org/t/error-principal-must-be-defined-only-once-in-the-type-namespace-of-this-module/17286 "2022-12-10T15:09:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![massimoalbarello](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/massimoalbarello/32/6041_2.png) [@massimoalbarello](https://forum.dfinity.org/u/massimoalbarello)\
**Post date:** [December 10, 2022, 3:09pm UTC](https://forum.dfinity.org/t/error-principal-must-be-defined-only-once-in-the-type-namespace-of-this-module/17286/1 "2022-12-10T15:09:10Z")

</div>

I have a canister which is importing two other canisters using:

```auto
#[ic_cdk_macros::import(canister = "environments_db")]
struct EnvironmentsDatabaseCanister;

#[ic_cdk_macros::import(canister = "user_profile_backend")]
struct UserProfileCanister;

```

In the `environments_db` canister I’m importing the `Principal` struct while in `user_profile_backend` I’m not. However, when I try building the project I get this error:

```auto
error[E0428]: the name `principal` is defined multiple times
  --> src/omnia_backend/src/lib.rs:26:1
   |
3 | #[ic_cdk_macros::import(canister = "user_profile_backend")]
   | ----------------------------------------------------------- previous definition of the type `principal` here
...
26 | #[ic_cdk_macros::import(canister = "environments_db")]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `principal` redefined here
   |
   = note: `principal` must be defined only once in the type namespace of this module
   = note: this error originates in the attribute macro `ic_cdk_macros::import` (in Nightly builds, run with -Z macro-backtrace for more info)

```

The only imports that I’m using in both imported canisters are `ic_cdk::api::call::ManualReply` and `candid::CandidType`.

Any idea why this is happening?

---

<div class="post-metadata">

**Author:** ![paulyoung](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/paulyoung/32/5251_2.png) [@paulyoung](https://forum.dfinity.org/u/paulyoung)\
**Post date:** [December 15, 2022, 6:50am UTC](https://forum.dfinity.org/t/error-principal-must-be-defined-only-once-in-the-type-namespace-of-this-module/17286/2 "2022-12-15T06:50:32Z")

</div>

@chenyan might be able to help. I suggest filing a GitHub issue though.

---

<div class="post-metadata">

**Author:** ![chenyan](https://avatars.discourse-cdn.com/v4/letter/c/35a633/32.png) [@chenyan](https://forum.dfinity.org/u/chenyan)\
**Post date:** [December 15, 2022, 5:12pm UTC](https://forum.dfinity.org/t/error-principal-must-be-defined-only-once-in-the-type-namespace-of-this-module/17286/3 "2022-12-15T17:12:30Z")

</div>

`import` doesn’t work at the moment. As a workaround, when you have the did file of the corresponding canister, you can run `didc bind user_profile_backend.did -t rs` to generate the Rust binding. We plan to integrate this inside cdk, but it’s not done yet.

---

<div class="post-metadata">

**Author:** ![massimoalbarello](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/massimoalbarello/32/6041_2.png) [@massimoalbarello](https://forum.dfinity.org/u/massimoalbarello)\
**Post date:** [December 16, 2022, 10:54am UTC](https://forum.dfinity.org/t/error-principal-must-be-defined-only-once-in-the-type-namespace-of-this-module/17286/4 "2022-12-16T10:54:56Z")

</div>

In my case `import` does work. The problem appears only if I use it twice to import two different canisters.  
You mean that I should run the command you suggested just for one of the two canisters while for the other I use `import`?

---

<div class="post-metadata">

**Author:** ![lastmjs](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/lastmjs/32/3406_2.png) [@lastmjs](https://forum.dfinity.org/u/lastmjs)\
**Post date:** [December 16, 2022, 2:27pm UTC](https://forum.dfinity.org/t/error-principal-must-be-defined-only-once-in-the-type-namespace-of-this-module/17286/5 "2022-12-16T14:27:22Z")

</div>

“Best practice” in Rust seems to be to just use `ic_cdk::api::call::call` when doing cross-canister calls. It’s more imperative but just works.
