hardhat icon indicating copy to clipboard operation
hardhat copied to clipboard

Artifact not found error right after compilation

Open alcuadrado opened this issue 2 years ago • 20 comments

Nico from balancer shared this error with me

$ hh compile --show-stack-traces
Nothing to compile
Error HH700: Artifact for contract "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/EnumerableSet.sol:EnumerableSet" not found. 

HardhatError: HH700: Artifact for contract "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/EnumerableSet.sol:EnumerableSet" not found. 
    at Artifacts._handleWrongArtifactForFullyQualifiedName (/home/nventuro/bal/v2/node_modules/hardhat/src/internal/artifacts.ts:457:11)
    at Artifacts._getValidArtifactPathFromFullyQualifiedNameSync (/home/nventuro/bal/v2/node_modules/hardhat/src/internal/artifacts.ts:566:19)
    at Artifacts._getArtifactPathSync (/home/nventuro/bal/v2/node_modules/hardhat/src/internal/artifacts.ts:322:19)
    at Artifacts.removeObsoleteArtifacts (/home/nventuro/bal/v2/node_modules/hardhat/src/internal/artifacts.ts:188:16)
    at SimpleTaskDefinition.action (/home/nventuro/bal/v2/node_modules/hardhat/src/builtin-tasks/compile.ts:1377:23)
    at Environment._runTaskDefinition (/home/nventuro/bal/v2/node_modules/hardhat/src/internal/core/runtime-environment.ts:217:35)
    at Environment.run (/home/nventuro/bal/v2/node_modules/hardhat/src/internal/core/runtime-environment.ts:129:25)
    at SimpleTaskDefinition.action (/home/nventuro/bal/v2/node_modules/hardhat/src/builtin-tasks/compile.ts:1407:11)
    at Environment._runTaskDefinition (/home/nventuro/bal/v2/node_modules/hardhat/src/internal/core/runtime-environment.ts:217:14)
    at Environment.run (/home/nventuro/bal/v2/node_modules/hardhat/src/internal/core/runtime-environment.ts:129:14)

He's getting an HH700 despite nothing being done.

I suspect this is a bug in our build-info clearing logic.

Will update with the list of plugins he is using.

alcuadrado avatar Apr 05 '22 21:04 alcuadrado

This issue is also being tracked on Linear.

We use Linear to manage our development process, but we keep the conversations on Github.

LINEAR-ID: fb369d0b-2187-4ae9-958a-fae624383ce8

github-actions[bot] avatar Apr 05 '22 21:04 github-actions[bot]

Plugins:

"@nomiclabs/hardhat-ethers@npm:^2.0.1":
  version: 2.0.2

"@nomiclabs/hardhat-etherscan@npm:latest":
  version: 2.1.6

alcuadrado avatar Apr 05 '22 21:04 alcuadrado

My friend, i meet the same problem

In the end, I found out that it was because hardhat could not find the contract, so I needed to specify the contract path for it.

Just modify the path in hardhat.config.ts, more information can be found here: https://hardhat.org/config/

Hope to help you

Screen Shot 2022-04-12 at 15 25 23

LuozhuZhang avatar Apr 12 '22 07:04 LuozhuZhang

Thanks, @hedgezhu!

I'm not sure if that can be a solution, as that's the default behavior of Hardhat.

alcuadrado avatar Apr 12 '22 15:04 alcuadrado

That's ok. Let's figure out how to fix this bug

LuozhuZhang avatar Apr 15 '22 03:04 LuozhuZhang

This is still not working even with paths specified. Arghhh this is so frustrating. What am I missing ? https://github.com/ihorbond/hardhat-test

ihorbond avatar May 13 '22 23:05 ihorbond

@ihorbond did you figure that out? The repo you linked doesn't exist anymore.

fvictorio avatar Jun 06 '22 16:06 fvictorio

@fvictorio yes there was a separate issue with Windows and glob package that I opened and you already fixed :)

ihorbond avatar Jun 07 '22 01:06 ihorbond

Glad to hear that!

fvictorio avatar Jun 07 '22 20:06 fvictorio

This issue was marked as stale because it didn't have any activity in the last 30 days. If you think it's still relevant, please leave a comment indicating so. Otherwise, it will be closed in 7 days.

github-actions[bot] avatar Jul 07 '22 20:07 github-actions[bot]

i meet the same problem, it works after clear cache:

rm -rf cache
rm -rf artifacts

ysqi avatar Jul 14 '22 07:07 ysqi

@ysqi you can use npx hardhat clean to do that.

fvictorio avatar Jul 14 '22 08:07 fvictorio

I tried doing npx hardhat clean and specifying the paths still not working. has anyone else figured it out yet?

mildlycoder avatar Sep 07 '22 17:09 mildlycoder

@codantes can you please open a new issue. This one is about an innocuous error that only happens very infrequently, and I suspect yours is a different one.

alcuadrado avatar Sep 07 '22 21:09 alcuadrado

I'm getting this problem in Github Actions specifically, so far haven't been able to consistently reproduce it locally. Even in Github Actions it happens something like half of the time. Really frustrating! Tried running clean (removing artifacts etc.) before hardhat compile, but right after hardhat compile sometimes the artifacts directory just doesn't contain the JSONs that other scripts expect.

jtakalai avatar May 26 '23 07:05 jtakalai

For me, it helped to downgrade Node.js from 18.16.0 to 18.12.1. I hope I can use the latest Node once this is fixed :)

jtakalai avatar May 26 '23 07:05 jtakalai

@mildlycoder have you figured it out?

Akaki2003 avatar Oct 11 '23 08:10 Akaki2003

If this happens during the removeObsoleteArtifacts phase, it means the artifact in the cache folder exists, but doesn't exist in artifacts. This is somewhat a rare case, as two conditions must be matched:

  • the artifacts folder was removed manually or in some clean-up process, but the cache folder wasn't.
  • some changes to the codebase must be made to remove some Contract dependency so that it is not emitted to the artifacts folder.

So after the compilation, Hardhat tries to clean the obsolete artifacts, that it finds in cache folder, but throws the error as it is not found in artifacts.

The workaround: make sure the cache folder is removed during the cleanup

Desired Hardhat fix: if the artifact can't be found in removeObsoleteArtifacts method, it should be silently skipped, as it was already successfully removed previously.

tenbits avatar Nov 02 '23 11:11 tenbits

in my case it was that the artifact file name was correct but the contract name didn't match the file name

Akaki2003 avatar Nov 02 '23 14:11 Akaki2003

@ysqi you are my hero :)

0xprinc avatar Jun 23 '24 13:06 0xprinc