truffle icon indicating copy to clipboard operation
truffle copied to clipboard

InternalCompilerError: Compiled contract not found.

Open Amxx opened this issue 4 years ago • 9 comments

Issue

After having deployed my contracts, and with artefacts in the /buildfolder, I cannot re-run truffle compile.

Calling truffle compile gives me:

InternalCompilerError: Compiled contract not found.

I could rm -rf ./build, but this would remove artefacts with deployment addresses I want to keep.

Environment

  • Operating System: Archlinux
  • Ethereum client: None involved here
  • Truffle version (truffle version): 5.1.22
  • node version (node --version): v10.16.3
  • npm version (npm --version): 6.14.4

Amxx avatar Apr 22 '20 07:04 Amxx

Sounds like there's two problems here:

  • InternalCompilerError's shouldn't happen, so that's something going wrong with Solidity. If we can get to the bottom of it, hopefully we'll be able to isolate the problem to bring up with them.
  • Something inside Truffle must be triggering this issue. Is your repo online? And can you share the artifacts in the current state? Maybe we can figure out what's going wrong.

Thanks @Amxx!

gnidan avatar Apr 22 '20 17:04 gnidan

To reproduce:

git clone [email protected]:Amxx/NFWallet.git
cd NFWallet
npm i
npm run build # works
touch contracts/NFWallet.sol      
npm run build # error

Amxx avatar Apr 22 '20 19:04 Amxx

I have the same issue,how to fix this?

coderbradlee avatar Jul 15 '20 02:07 coderbradlee

@gnidan I have the same issue

pefish avatar Sep 29 '20 02:09 pefish

I have a reliable repro for this in https://github.com/ethereum/solidity/issues/7627#issuecomment-705613016

This is an issue in the compiler that happens in pretty specific circumstances (when recompiling several contracts but requesting output only for some of them and when some specific language features are used).

It's going to be fixed in Solidity but for the time being a workaround is just to force Truffle to recompile everything (e.g. by removing the build/ directory).

cameel avatar Oct 08 '20 16:10 cameel

I could rm -rf ./build, but this would remove artefacts with deployment addresses I want to keep.

Another way to force a recompile would be to run touch on all contracts to update their modification date. Or not necessarily on all of them - just the ones that are triggering this issue, though it might be hard to track down which ones those are.

cameel avatar Oct 08 '20 16:10 cameel

You can also do truffle compile --all or truffle test --compile-all

gnidan avatar Oct 08 '20 19:10 gnidan

Just to let you know: this bug is now fixed Solidity 0.7.4.

cameel avatar Oct 27 '20 21:10 cameel

EDIT: I managed to fix my problem - that said, i did hit InternalCompilerError: Compiled contract not found. with npx hardhat compile, by having a contract try to get its own .creationCode. I suppose this comment is on the wrong issue, since this is apparently for truffle, but I don't recall seeing another issue open for this error message, so I commented here.

Orig text:

I'm getting InternalCompilerError: Compiled contract not found. with npx hardhat compile Seems like there are still some issues. Since a repro was mentioned above, don't want to cut a minimal repro right now. This issue has persisted even after i deleted artifacts and cache and even after I changed the part of the code that I thought may have been causing the issue.

EDIT: I've boiled this down to the issue - I want to use create2 to put my contract at a specific address, and then i want other contracts to know the address I've deployed to. So I have:

Contract A {
    address public constant myAddr =
      address(uint160(uint(keccak256(abi.encodePacked(
        bytes1(0xff),
        /* Addr to deploy with */,
        uint256(/* Salt */),
        keccak256(abi.encodePacked(type(A).creationCode))
      )))));
... }

But naturally .creationCode can't really work since it hasn't been compiled yet. EDIT: I realized the way to fix this is to move myAddr out of the contract but into the same file as the contract.

NeverFearTomorrow avatar Aug 29 '22 06:08 NeverFearTomorrow