hardhat icon indicating copy to clipboard operation
hardhat copied to clipboard

Unable to resolve import: "INSERT_CONTRACT" with remappings when using NPM workspaces

Open kamescg opened this issue 3 years ago • 2 comments

The situation

I have Turborepo + pnpm project setup; a workspaces monorepo with a symlink dependency graph.

When running hardhat compile with the foundry-rs/hardhat-* plugins installed I get the following mapping errors.

[⠊] Compiling...
[⠒] Unable to resolve import: "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol" with remappings:
        contracts/=/Users/kames/workspace/kames/code/turbo-eth/contracts/
[⠢] Unable to resolve import: "@openzeppelin/contracts/access/Ownable.sol" with remappings:
        contracts/=/Users/kames/workspace/kames/code/turbo-eth/contracts/
[⠆] Unable to resolve import: "@openzeppelin/contracts/token/ERC20/IERC20.sol" with remappings:
        contracts/=/Users/kames/workspace/kames/code/turbo-eth/contracts/
...
...
...
[⠊] Unable to resolve import: "../../node_modules/zeppelin-solidity/contracts//math/SafeMath.sol" with remappings:
        contracts/=/Users/kames/workspace/kames/code/turbo-eth/contracts/

This is obviously a problem with my monorepo build system, but just wanted to flag this issue.

Maybe someone has an idea for a good work-around to get foundry-rs to work nicely in an NPM workspaces build setup?

kamescg avatar Jun 19 '22 10:06 kamescg

What do your remappings, filesystem and deps look like? I'm not sure if this is a problem with the hardhat plugin, foundry/ethers-rs or your config. I was able to use foundry within a monorepo to import other packages in the Optimism monorepo, although we have refactored it to no longer need to import contracts from other packages.

tynes avatar Jun 20 '22 19:06 tynes

Let me double check all the configurations and I will get back to you. I ran the same smart contract repo outside of the monorepo and it compiled without any of the remapping warnings, so I assume I everything was fine, but I also may have missed something else and I just want to double check before I look foolish ;)

kamescg avatar Jun 20 '22 21:06 kamescg