# Dfx deploy failure when importing a pulled canister

**URL:** <https://forum.dfinity.org/t/dfx-deploy-failure-when-importing-a-pulled-canister/66165>\
**Category:** Developers\
**Created:** [March 29, 2026, 3:06am UTC](https://forum.dfinity.org/t/dfx-deploy-failure-when-importing-a-pulled-canister/66165 "2026-03-29T03:06:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![myklenero](https://avatars.discourse-cdn.com/v4/letter/m/a9adbd/32.png) [@myklenero](https://forum.dfinity.org/u/myklenero)\
**Post date:** [March 29, 2026, 3:06am UTC](https://forum.dfinity.org/t/dfx-deploy-failure-when-importing-a-pulled-canister/66165/1 "2026-03-29T03:06:08Z")

</div>

I have a canister that is importing the Ledger canister via `import ic:ryjl3-tyaaa-aaaaa-aaaba-cai`. When I run `dfx deploy`, I get an error:

```auto
~/dfx-deploy-failure-example/src/dfx-deploy-failure-example-backend/store/main.mo:1.1-1.47: import error [M0009], file "~/dfx-deploy-failure-example/.dfx/local/canisters/idl/ryjl3-tyaaa-aaaaa-aaaba-cai.did" does not exist

```

I would expect `ryjl3-tyaaa-aaaaa-aaaba-cai.did` to be created before the `store` canister is built but that doesn’t seem to be the case.

Here is a small example repo:

> **[GitHub - MykleNero/dfx-deploy-failure-example](https://github.com/MykleNero/dfx-deploy-failure-example)**
>
> Contribute to MykleNero/dfx-deploy-failure-example development by creating an account on GitHub.

Any help here would be appreciated!

Additional context:  
moc version: `Motoko compiler 1.1.0 (source q8nbql1z-ylg40zah-wmfljwd6-j6bq1lwd)`

dfx version: `dfx 0.31.0`

---

<div class="post-metadata">

**Author:** ![myklenero](https://avatars.discourse-cdn.com/v4/letter/m/a9adbd/32.png) [@myklenero](https://forum.dfinity.org/u/myklenero)\
**Post date:** [March 29, 2026, 3:15am UTC](https://forum.dfinity.org/t/dfx-deploy-failure-when-importing-a-pulled-canister/66165/2 "2026-03-29T03:15:58Z")

</div>

Doing some testing, it appears this is related to the name of the canister. Changing the name from `store` to anything alphabetically earlier than `icp_ledger` (i.e. `foo`) fixes the problem.

Even still, I would expect the dependencies arg in dfx.json to control the order that the canisters are built.

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [March 30, 2026, 9:15am UTC](https://forum.dfinity.org/t/dfx-deploy-failure-when-importing-a-pulled-canister/66165/3 "2026-03-30T09:15:11Z")

</div>

There’s a bad dependency in the repo I think… Anyways, after removing the superfluous `mops.toml` dependencies I can reproduce the issue, thanks a lot for the repo!

Turns out dfx ignores what you declare as dependencies for Motoko canisters in `dfx.json`, and instead asks `moc`, the Motoko compiler, what canisters your imports depend on. I could probably fix it, but we put minimal effort into dfx now in favor of icp-cli.

What you can change in your project setup to make `moc` report the ledger as a dependency is to change your import statement from `import Ledger "ic:ryjl3-tyaaa-aaaaa-aaaba-cai";` to `import Ledger "canister:icp_ledger";`. With this change the project deploys just fine in my local setup, no matter what name I give the ICP ledger

---

<div class="post-metadata">

**Author:** ![taimoor\_dev](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/taimoor_dev/32/30432_2.png) [@taimoor\_dev](https://forum.dfinity.org/u/taimoor_dev)\
**Post date:** [March 30, 2026, 8:40pm UTC](https://forum.dfinity.org/t/dfx-deploy-failure-when-importing-a-pulled-canister/66165/4 "2026-03-30T20:40:39Z")

</div>

Hey, thanks for the repo, this helps a lot to understand the issue.

This usually happens because moc resolves dependencies itself instead of relying on dfx.json, which can mess up the build order.

A simple fix is to use the canister alias instead of the raw canister id:

```auto
import Ledger "canister:icp_ledger";

```

This makes the dependency explicit and fixes the deploy issue in most cases.

---

<div class="post-metadata">

**Author:** ![myklenero](https://avatars.discourse-cdn.com/v4/letter/m/a9adbd/32.png) [@myklenero](https://forum.dfinity.org/u/myklenero)\
**Post date:** [March 30, 2026, 10:24pm UTC](https://forum.dfinity.org/t/dfx-deploy-failure-when-importing-a-pulled-canister/66165/5 "2026-03-30T22:24:16Z")

</div>

Ah this makes sense. Thank you for your help @vivienne! Thank you as well @taimoor_dev!
